我晕了!这么水的题,我居然WA了N 次,,,就是自己没有理解好题意最后还对ENDOFINPUT进行了输出处理
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4int main ()
5{
6
char start[11];
7
char end[4];
8
char cipher[201];
9
int len;
10
11
scanf ("%s", start);
12
while ( strcmp (start, "ENDOFINPUT") )
13
{
14
getchar ();
15
16
gets (cipher);
17
18
getchar ();
19
20
scanf ("%s", end);
21
22
//对密文进行解密
23
len = strlen (cipher);
24
for (int i = 0; i < len; i ++)
25
{
26
if ( ('A' <= cipher[i]) && ( cipher[i] <= 'Z') )
27
{
28
if ( 70 <= cipher[i] && cipher[i] <= 90)
29
printf ("%c", cipher[i] - 5);
30
else
31
printf ("%c", cipher[i] + 21);
32
}
33
else
34
printf ("%c", cipher[i]);
35
}
36
printf ("\n");
37
scanf ("%s", start);
38
}
39
//printf ("ENDOFINPUT\n"); 画蛇添足
40
//system ("pause");
41
return 0;
42
}
43
posted on 2010-08-05 16:00
雪黛依梦 阅读(452)
评论(0) 编辑 收藏 引用 所属分类:
字符串处理题