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 <cstring> #include <algorithm> using namespace std; int main() { char str[100][51]; int n,m,i,j,k,total[100] = {0},count,max = 0; cin >> n >> m; cin.get(); for(i = 0;i < m;i++) cin.getline(str[i],50,'\n'); for(i = 0;i < m;i++){ count = 0; for(j = 0;j < n - 1;j++) for(k = j + 1;k < n;k++) if(str[i][k] < str[i][j]) count++; total[i] = count; if(count > max) max = count; } for(i = 0;i <= max;i++) for(j = 0;j < m;j++) if(total[j] == i) cout << str[j] << 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