| ||||||||||
| 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 | |||||||||
个人觉得代码已经正确了,而且细节问题基本都注意了,但是就是一直WA,请高人指点#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAXSIZE 200
int main(void)
{
int pos,temp,accum,queue[MAXSIZE],count,record[MAXSIZE];
unsigned int len,i,n;
char str[MAXSIZE];
char final[MAXSIZE];
while(scanf("%d",&n) && (n!=0))
{
for(i=0;i<n;i++)
{
scanf("%d",&queue[i]);
}
while(scanf("%d",&accum) && (accum!=0))
{
getchar();
gets(str);
len=strlen(str);
for(i=0;i<n-len;i++)
{
str[len+i]=' ';
}
str[len+i]='\0';
for(i=0;i<n;i++)
{
pos=temp=i;
count=1;
record[0]=i;
while(pos!=(queue[temp]-1))
{
temp=queue[temp]-1;
record[count]=temp;
count++;
}
final[record[accum%count]]=str[i];
}
final[n]='\0';
printf("%s\n",final);
}
printf("\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator