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 <memory.h> char str[210],shift[210],temp1[210],temp2[210]; int n,k,t,tt,m; void getTimes() { char flag[210]; int time; int i,j,c,kk,t,tt; for(i=0;i<=n;i++) flag[i]=0; t=0; m=0; for(i=1;i<=n;i++) { if(flag[i]==0) { c=1; flag[i]=1; j=shift[i]; while(flag[j]==0) { c++; flag[j]=1; j=shift[j]; } time=c; c=k%time; for(j=0;j<time;j++) { kk=i; t=j; while(t){kk=shift[kk];--t;} tt=kk; t=c; while(t){kk=shift[kk];--t;} temp2[kk]=temp1[tt]; } } } } int main() { int i; char ch; scanf("%d",&n); while(n!=0) { for(i=1;i<=n;i++) scanf("%d",shift+i); scanf("%d",&k); ch=getchar(); while(k!=0) { gets(str); for(i=strlen(str);i<=n;i++) str[i]=' '; for(i=1;i<=n;i++) temp1[i]=i-1; getTimes(); for(i=0;i<n;i++) printf("%c",str[temp2[i+1]]); printf("\n"); scanf("%d",&k); ch=getchar(); } scanf("%d",&n); if(n) printf("\n"); } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator