Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
纪念第一百道,仍然疑问!很奇怪,我在排序的时候觉得两种方法的结果应该一样,但是却一个ac一个wa。谁帮我! ac: bool flag[10]={false}; for(int i=0;i<len1;i++) { int lable=0; while(flag[lable])lable++; char dis=array1[lable]; for(int j=lable+1;j<len1;j++) { if(!flag[j]&&(array1[j]<dis)) { lable=j; dis=array1[lable]; } } flag[lable]=true; num[i]=lable; } wa: for(int i=0;i<len1;i++) { num[i]=i; } for(int j=0;j<len1-1;j++) { for(int k=j+1;k<len1;k++) { if(array1[j]>array1[k]) { temp1=array1[j]; array1[j]=array1[k]; array1[k]=temp1; temp2=num[j]; num[j]=num[k]; num[k]=temp2; } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator