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

为什么c++会WA G++却AC??

Posted by gaosimeng at 2007-02-21 00:37:30 on Problem 1107
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
	char s[80],c,cc;
	int l,i,a[80],k[3],j,t;
	while(cin>>k[0]>>k[1]>>k[2]&&(k[0]||k[1]||k[2]))
	{
		cin>>s;
		l=strlen(s);
		for(i=0;i<l;i++)
		{
			if(s[i]>='a'&&s[i]<='i')
				a[i]=0;
			else if(s[i]>='j'&&s[i]<='r')
				a[i]=1;
			else if((s[i]>='s'&&s[i]<='z')||s[i]=='_')
				a[i]=2;
		}
		for(t=0;t<3;t++)
		{
			while(k[t]-->0)
			{
				for(j=0;j<l;j++)
					if(a[j]==t)
						break;
				c=s[j];
				for(i=j;i<l;i++)
					if(a[i]==t)
					{
						cc=s[i];
						s[i]=c;
						c=cc;
					}
				s[j]=c;
			}
		}
		cout<<s<<endl;
	}
	return 0;
}







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