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

很多人都说这个题目难,但这个题目是很简单的.

Posted by dljlw at 2007-06-11 22:10:10 on Problem 1107
#include<stdio.h>
#include<string.h>

int main()
{
	while(1)
	{
		char tmp[81],ch;
		char s[81];
		int mark[81];
		int i,k1,k2,k3,j,t,k;
		scanf("%d%d%d",&k1,&k2,&k3);
		if(!k1 && !k2 && !k3)break;
		scanf("%s",s);
		memset(tmp,0,sizeof(char)*81);
		for(i=0;i<3;i++)
		{
			t=0;
			memset(mark,0,sizeof(int)*81);
			if(i==0)
			{
				for(j=0;j<strlen(s);j++)if(s[j]>='a' && s[j]<='i'){tmp[t++]=s[j];mark[j]=1;}t--;
				for(j=0;j<k1;j++)
				{
					ch=tmp[t];
					for(k=t;k>=0;k--)tmp[k]=tmp[k-1];
					tmp[0]=ch;
				}
				t=0;
				for(j=0;j<strlen(s);j++)if(mark[j])s[j]=tmp[t++];
			}
			else if(i==1)
			{
				for(j=0;j<strlen(s);j++)if(s[j]>='j' && s[j]<='r'){tmp[t++]=s[j];mark[j]=1;}t--;
				for(j=0;j<k2;j++)
				{
					ch=tmp[t];
					for(k=t;k>=0;k--)tmp[k]=tmp[k-1];
					tmp[0]=ch;
				}
				t=0;
				for(j=0;j<strlen(s);j++)if(mark[j])s[j]=tmp[t++];
			}
			else
			{
				for(j=0;j<strlen(s);j++)if((s[j]>='s' && s[j]<='z') || s[j]=='_'){tmp[t++]=s[j];mark[j]=1;}t--;
				for(j=0;j<k3;j++)
				{
					ch=tmp[t];
					for(k=t;k>=0;k--)tmp[k]=tmp[k-1];
					tmp[0]=ch;
				}
				t=0;
				for(j=0;j<strlen(s);j++)if(mark[j])s[j]=tmp[t++];
			}
		}
		printf("%s\n",s);
	}
	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