Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪位路过的大牛帮我看看为什么会WA

Posted by lironghua at 2007-04-26 15:52:49 on Problem 1007
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator