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 |
测试数据没有问题,但就是不过,求大神帮助!#include <iostream> #include <cstdlib> using namespace std; int main() { int n, m; cin >> n >> m; char str[m][n+5]; for(int i = 0; i < m; i++) cin >> str[i]; int arr[m+5]; for(int i = 0; i < m; i++) { int sum = 0; for(int j = 0; j < n - 1; j++) { int t = j + 1; while(t < n) { if(str[i][j] > str[i][t]) sum++; t++; } arr[i] = sum; } } int brr[m+5]; for(int i = 0; i < m; i++) { int j = 0; int min = arr[j]; int temp = j; for( ; j < m - 1; j++) { if(arr[j+1] != 100 && min > arr[j+1]) { min = arr[j+1]; temp = j+1; } } arr[temp] = 100; brr[i] = temp; } for(int i = 0; i < m; i++) cout << str[brr[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