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 iammk at 2009-03-23 07:58:55
#include<stdio.h>
#include<string.h>
#include<malloc.h>
void main()
{
	int *a,n,k,i,len,count=0;
	char *str,*temp;
	while(1)
	{
		scanf("%d",&n);
		if(n==0)
			break;
		else
		{
			a=(int*)malloc(n*sizeof(int));
			for(i=0;i<n;i++)
				scanf("%d",&a[i]);				
			str=(char*)malloc((n+1)*sizeof(char));
			temp=(char*)malloc((n+1)*sizeof(char));
			scanf("%d",&k);
			while(k!=0)
			{
				getchar();
				gets(str);
				len=strlen(str);
				for(i=len;i<n;i++)
					str[i]=' ';
				str[n]='\0';
				while(k!=0)
				{
					for(i=0;i<n;i++)
					{
						temp[a[i]-1]=str[i];
					}
					strcpy(str,temp);
					str[n]='\0';
					k--;
					count++;
					if(strcpy(str,temp)==0)
						k=k%count;
					str[n]='\0';
				}	
				puts(str);
				scanf("%d",&k);
			}
		}
	}
}

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