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 |
Re:就是不知道自己错在那里,在本机上VS和G++都通过的,一提交就是runtime errorIn Reply To:就是不知道自己错在那里,在本机上VS和G++都通过的,一提交就是runtime error Posted by:liuweni at 2006-11-28 15:08:22 > #include <iostream> > #include <string> > > using namespace std; > int i; > void sort(int num[],string str[],int first ,int last) > { > int itemp; > string stemp; > if(first == last) > return; > > for(i = first ; i != last ; i++) > { > if( num[first] > num[i]) > { > itemp = num[i];num[i] = num[first];num[first] = itemp; > stemp = str[i];str[i] = str[first];str[first] = stemp; > } > } > for(i = last ; i != first ;i--) > { > if(num[last] < num[i]) > { > itemp = num[i];num[i] = num[last];num[last] = itemp; > stemp = str[i];str[i] = str[last];str[last] = stemp; > } > } > sort(num,str,first + 1,last); > sort(num,str,first,last - 1); > } > int main() > { > int a,b; > int *num; > string *str; > cin>>a; > num = new int[a]; > str = new string[a]; > cin>>b; > for(i = 0 ; i < b ; i++) > { > cin>>str[i]; > num[i] = 0; > > for(int j = 0 ; j < a ;j ++) > { > for(int ii = j ;ii < a ;ii++) > { > if(str[i][j]>str[i][ii]) > { > num[i] ++; > } > } > } > } > sort(num , str , 0 , b-1); > > for(i = 0 ; i < b ; i++) > { > cout<<str[i]<<endl; > } > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator