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 |
哪位同学能帮忙看一下c++代码,我们只学到了数组还有循环,所以比较麻烦#include<iostream> using namespace std; int main() { char litter[100][50] = {}; int n = 0,m = 0; int temp[50] = {0}; cin>>n>>m; for(int k=0;k<m;k++) { for(int l=0;l<n;l++) { cin>>litter[k][l]; } } for(int p=0;p<m;p++) { for(int k=0;k<n;k++) { for(int l=k+1;l<n;l++) { while(litter[p][k]>litter[p][l]) { temp[p]++; break; } } } } int number[50] = {0}; for(int k=0;k<m;k++) { number[k] = temp[k]; } int t = 0; for(int k=0;k<m;k++) { for(int l=k+1;l<m;l++) { if(temp[k]>temp[l]) { t = temp[l]; temp[l] = temp[k]; temp[k] = t; } } } for(int k=0;k<m;k++) { for(int l=0;l<m;l++) { if(temp[k]==number[l]) { for(int p=0;p<n;p++) { cout<<litter[l][p]; } cout<<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