| ||||||||||
| 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 | |||||||||
菜鸟求救。。。。1007#include <iostream>
using namespace std;
struct info
{
int index;
int count;
};
int main()
{
int n,m,i,count,j,v;
cin >> n;
cin >> m;
char a[100][50];
info io[100],t;
for (i = 0;i < m;i++)
{
cin >> a[i];
count = 0;
for (v = 0; v < n; v++)
for (j = v+1; j < n; j++)
if (a[i][v] > a[i][j])
count++;
io[i].index = i;
io[i].count = count;
}
for (i = 0; i < m;i++)
{
v = i;
for (j = i+1; j < m;j++)
if (io[v].count > io[j].count)v = j;
if (v != i)
{
t = io[i];
io[i] = io[v];
io[v] = t;
}
}
for (i = 0; i < m;i++)
cout << a[io[i].index] << endl;
return 0;
}
交上了,结果是WA。看了老半天,不知道错了哪?哪位高手帮忙指点一下?小弟先道声谢谢了。。。
:)
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator