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

较笨的方法,一次ac

Posted by conan614 at 2009-10-24 22:20:14 on Problem 1107
/*
acm 1107 1次ac
方法比较笨
248K 0MS 
*/
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int a;
	int j;
	int s;
	string data[100];
	string result[100];
	int state1[80];
	int state2[80];
	int state3[80];
	int n=0;
	int count1=0;
	int count2=0;
	int count3=0;
	while(1)
	{
		cin>>a;
		cin>>j;
		cin>>s;
		if(a==0&&j==0&&s==0)
			break;
		cin>>data[n];
		result[n]=data[n];
		int length=data[n].length();
			for(int i=0;i<length;i++)//找到位置
			{
				if(data[n][i]>='a'&&data[n][i]<='i')
				{
					state1[count1++]=i;
				}
				if(data[n][i]>='j'&&data[n][i]<='r')
				{
					state2[count2++]=i;
				}
				if((data[n][i]>='s'&&data[n][i]<='z')||data[n][i]=='_')
				{
					state3[count3++]=i;
				}
			}
			for(int k=0;k<count1;k++)
			{
				result[n][state1[(k+a)%count1]]=data[n][state1[k]];
			}
			for(int k=0;k<count2;k++)
			{
				result[n][state2[(k+j)%count2]]=data[n][state2[k]];
			}
			for(int k=0;k<count3;k++)
			{
				result[n][state3[(k+s)%count3]]=data[n][state3[k]];
			}
					n++;
					count1=0;
					count2=0;
					count3=0;
	}
	for(int k=0;k<n;k++)
		cout<<result[k]<<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