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 |
为什么总是出现runtime error?是不是循环太多了?帮忙啊!大侠们!!#include<iostream> using namespace std; int main() { int n,m,i,j,k,count,min; int sort[50]; int flag[50]; char str[100][50],temp; cin>>n>>m; for(i=0;i<m;i++) { for(j=0;j<n;j++) cin>>str[i][j]; } cout<<endl; for(i=0;i<m;i++) { count=0; for(j=0;j<n-1;j++) { temp=str[i][j]; for(k=j+1;k<n;k++) { if((temp-str[i][k])>0) count++; } } sort[i]=count; } for(k=0;k<m;k++) { min=sort[0]; flag[k]=0; for(i=0;i<m;i++) { if(min>sort[i]) { min=sort[i]; flag[k]=i; } } sort[flag[k]]=100; } for(i=0;i<m;i++) { k=flag[i]; for(j=0;j<n;j++) cout<<str[k][j]; cout<<endl; } system("pause"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator