Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 我实在找不出错了,哪位大大有时间帮我看看,Sample Input可以得到正确的答案

Posted by windbells at 2004-08-07 23:28:35 on Problem 1453
```是不是命令后的空格也要输出

#include<stdio.h>
#include<string.h>
int main()
{
int i,size,brry[26],key,flag;
for(i=0;i<26;i++)
{
clj[i]=i+'A';//值对应的字母
brry[i]=i;//字母对应的值
}
{
gets(arry);
size=strlen(arry);pre='A';
{
for(i=0;i<size;i++)
{
if(arry[i]>='a'&&arry[i]<='z')
{
tmp=arry[i];
arry[i]=clj[(brry[arry[i]-'a']-brry[pre-'A']+26)%26];
pre=tmp-32;
if(arry[i]>='A'&&arry[i]<='Z')
arry[i]+=32;
}
else if(arry[i]>='A'&&arry[i]<='Z')
{

tmp=arry[i];
arry[i]=clj[(brry[arry[i]-'A']-brry[pre-'A']+26)%26];
pre=tmp;
if(arry[i]>='a'&&arry[i]<='z')
arry[i]-=32;
}
else pre='A';
}
printf("RESULT: %s\n",arry);
}
{
for(i=0;i<size;i++)
{
if(arry[i]>='a'&&arry[i]<='z')
{
arry[i]=clj[(brry[pre-'A']+brry[arry[i]-'a'])%26];
pre=arry[i];
if(arry[i]>='A'&&arry[i]<='Z')
arry[i]+=32;
}
else if(arry[i]>='A'&&arry[i]<='Z')
{

arry[i]=clj[(brry[pre-'A']+brry[arry[i]-'A'])%26];
pre=arry[i];
if(arry[i]>='a'&&arry[i]<='z')
arry[i]-=32;
}
else pre='A';
}
printf("RESULT: %s\n",arry);
}
{
for(i=0;i<26;i++)
brry[i]=26;
key=0;flag=1;
for(i=0;i<size;i++)
{
if(arry[i]>='a'&&arry[i]<='z')
{
clj[key++]=arry[i]-32;
if(brry[arry[i]-'a']!=26)
{
flag=0;
break;
}
else brry[arry[i]-'a']=key-1;
}
else if(arry[i]>='A'&&arry[i]<='Z')
{
clj[key++]=arry[i];
if(brry[arry[i]-'A']!=26)
{
flag=0;
break;
}
else brry[arry[i]-'A']=key-1;
}
if(flag==0)
break;
}
if(key!=26)
flag=0;
if(flag==0)
{
for(i=0;i<26;i++)
{
clj[i]=i+'A';
brry[i]=i;
}
}
else
{
printf("Good cipher.  Using ");
for(i=0;i<26;i++)
printf("%c",clj[i]);
printf(".\n");
}
}
else printf("Command not understood.\n");
}
return 0;
}

```

Followed by: