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 |
求解,为什么是WA?#include <iostream> #include <cstdlib> using namespace std; char str[100][50]; int num[100];//每一行的逆序对数 int flag[100]; int ssort[100]; int main() { int n,m; cin>>n>>m; if(n<=0||n>50||m<=0||m>100) return 0; int a=0,b=0;//计数器 int lcount; for(a=0;a<m;a++) { num[a]=0; flag[a]=0; ssort[a]=0; int count=0; for(count=0;count<n;count++) { cin>>str[a][count]; }//得到一行字符串 for(count=0;count<n;count++) { for(lcount=count;lcount<n;lcount++) { if(str[a][count]>str[a][lcount]) num[a]++; } }//得到逆序对数 } for(a=0;a<m;a++) { for(lcount=0;lcount<m;lcount++) { if(num[a]>=num[lcount]) flag[a]++; } flag[a]=flag[a]*1000+a; }//得到flag值 for(a=0;a<m;a++) { for(lcount=0;lcount<m;lcount++) { if(flag[a]<=flag[lcount]) ssort[a]++; } }//处理flag值并转为ssort值 for(a=m;a>1;a--) { for(b=0;b<n;b++) { if(ssort[b]==a) { int p; for(p=0;p<n;p++) { cout<<str[b][p]; } } } cout<<endl; } for(b=0;b<n;b++) { if(ssort[b]==1) { int q; for(q=0;q<n;q++) { cout<<str[b][q]; } } } 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