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

多了一个cout<<endl; 结果老是pe,下面贴出我的经典代码!

Posted by acmyinshiyong at 2011-08-14 10:53:41
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s[1000], temps;
	int EachLen, CaseNum, i, j, k, a[1000], count, temp;
	while(cin>>EachLen>>CaseNum)
	{	
		for(i=0; i<CaseNum; i++)  ///获取每个串的长度,a[i]
		{
			count=0;
			cin>>s[i];
			for(j=0; j<EachLen-1; j++)
				for(k=j+1; k<EachLen; k++)
				{
					if(s[i][j]>s[i][k])
					{
						count++;
					}
					
				}
			a[i] = count;
		}
		for(i=0; i<CaseNum; i++)  ///根据a[i],来排序字符串
		{
			for(j=i+1 ; j<CaseNum; j++)
			{
				if(a[i]>a[j])
				{
					temp = a[i]; a[i] = a[j]; a[j] = temp;
					temps = s[i]; s[i] = s[j]; s[j] = temps;
				}
			}
		}
		
		for(i=0; i<CaseNum; i++)
			cout<<s[i]<<endl;
	}
}
数组开的小了,老是re,所以大点无所谓了。

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