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

在DEV C++上运行正确怎么在这里就是WA呢?每一项循环都求模了

Posted by phantomr at 2005-04-28 23:16:51 on Problem 1026
#include<stdio.h>
#include<string.h>
int t(int key[],int i)
{
    int k,j=i;
    for(k=1;(j=key[j]-1)!=i;k++);
    return k;
}    

main()
{
    int key[2][200],n,i,j,k;
    char mes[2][200],enco[200];
    for(;;)
    {
    scanf("%d",&n);
    if(n==0) break;
    
    for(i=0;i<n;i++)
    scanf("%d",&key[0][i]);
    
    for(i=0;i<n;i++)
    key[1][i]=t(key[0],i);
    
    for(;;)
    {
    scanf("%d",&k);
    if(k==0) break;
    
    getchar();
    gets(mes[0]);
    
    for(i=0;mes[0][i]!='\0';i++)
    mes[1][i]=i;    
    
    for(i=0;mes[0][i]!='\0';i++)
   {if(mes[0][i]==' ') continue;
    for(j=k%key[1][i];j>0;j--)
    mes[1][i]=key[0][mes[1][i]]-1;}
    
    for(i=0;i<n;i++)
    enco[i]=' ';
    enco[n]=0;
    
    for(i=0;mes[0][i]!='\0';i++)
    enco[mes[1][i]]=mes[0][i];    
    printf("%s\n",enco);
    }
    printf("\n");    
    }
}    

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