| ||||||||||
| 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 <algorithm>
#include <functional>
using namespace std;
typedef struct sum {
int idx;
int s;
}sum;
bool operator < (const sum &a,const sum &b)
{
return a.s < b.s;
}
int main ()
{
#ifndef ONLINE_JUDGE
freopen ("DNA Sorting.txt","r",stdin);
#endif
char a[100][50];
sum ss[100];
int m,n,i,j,k;
cin >> m >> n;
for (i = 0; i < n; i++)
{
scanf ("%s",a[i]);
ss[i].s = 0;
}
for (i = 0; i < n; i++)
{
ss[i].idx = i;
for (j = 0; j < m; j++)
{
for (k = j + 1; k < m; k++)
if (a[i][j] > a[i][k])
{
ss[i].s++;
}
}
}
for (i = 0; i < n; i++)
cout << ss[i].s << endl;
stable_sort(ss,ss+n,less<sum>());//稳定排序
for (i = 0; i < n; i++)
cout << ss[i].s << endl;
for (i = 0; i < n; i++)
{
printf ("%s\n",a[ss[i].idx]);
}
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator