| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
这是我的代码,那位高手帮我看看啊,谢谢总超时!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator