error C2601: 'main' : local function definitions are illegal
fatal error C1004: unexpected end of file found
#include"iostream" #include"iomanip" using namespace std; void Swap(int &a,int &b){//交换 int temp; temp=a; a=b; b=temp; }//Swap int PivotList(int list[],int first,int last){ int pivotValue,pivotPoint,index; pivotValue=list[first];//用来存储pivot的值 pivotPoint=first;//pivot地址下标 for(index=first+1;index<=last;index++) if(list[index]<pivotValue){ pivotPoint=pivotPoint+1; Swap(list[pivotPoint],list[index]); }//if Swap(list[first],list[pivotPoint]); return pivotPoint; }//PivotList void QuickSort(int List[],int First,int Last){ int i,pivot;//区分>pivot和<pivot的元素 if(First<Last){ pivot=PivotList(List,First,Last); QuickSort(List,First,pivot-1); QuickSort(List,pivot+1,Last); }//if cout<<"The new list is:\n"; for(i=1;i<=100;i++){ cout<<setw(2)<<List[i]<<" "; if(i%10==0) cout<<"\n"; }//QuickSort int main(){ int a[101],i,endFlag; a[0]=0; for(i=1;i<101;i++){ a[i]=rand()%100; a[0]++; }//for cout<<"\nThe original elements are:\n"; for(i=1;i<101;i++){ cout<<setw(2)<<a[i]<<" "; if(i%10==0) cout<<"\n"; }//for cout<<endl<<endl; QuickSort(a,1,100);//1=>first,100=>end cout<<"\nEnd?OK,please press 1 \n";//使用endFlag作为结束前的标志 cin>>endFlag; return 0; }//main