精華區beta NTUCH-HW 關於我們 聯絡資訊
功能 用到的觀念 CODE /*PROGRAMMER :楊翔斌*/ /*DATE :2010-1-7*/ /*FILENAME :HW07B002.cpp*/ /*DESCRIPTION:sort the data*/ #include "stdafx.h" #include <iostream> #include <iomanip> using namespace std; #include <string> #include <fstream> #include "sortfile.h" #include <cstdlib> int main() { const int n=35;//set a constant string filename="unsorted.txt",name[n],temps,otherword[6]; double numA[n][10],temp,matrix3[n][10]; int row1,column1,i,j,k,a; sortfile call,arrange;//declare the object cout << "Please enter the name of the file you wish to open: "; cin>>filename;//enter a file name call.input(filename,row1,column1,matrix3,name,otherword);//call the function to get the data cout<<otherword[0]<<endl; cout<<otherword[1]<<endl; cout<<otherword[2]<<endl; for(int ii=0;ii<row1;ii++)//print the original matrix { cout<<setw(10)<<left<<name[ii]; for(int jj=0;jj<column1;jj++) { cout<<left<<"\t"<<matrix3[ii][jj]; } cout<<endl; } cout<<otherword[3]<<endl; cout<<"arrange in the order of inballs, press 1. "<<endl;//show the content cout<<"arrange in the order of free ball, press 2."<<endl; cin>>a; if(a==1) { cout<<"in the order of inballs"<<endl; cout<<otherword[0]<<endl; cout<<otherword[1]<<endl; cout<<otherword[2]<<endl; arrange.sort02(matrix3,name,numA,row1,column1,otherword);//call the sort function to sort the data } else if(a==2) { cout<<"in the order of free ball"<<endl; cout<<otherword[0]<<endl; cout<<otherword[1]<<endl; cout<<otherword[2]<<endl; arrange.sort05(matrix3,name,numA,row1,column1,otherword); } system("pause"); return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.7.59