posts - 99,  comments - 8,  trackbacks - 0

我晕了!这么水的题,我居然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 雪黛依梦 阅读(444) 评论(0)  编辑 收藏 引用 所属分类: 字符串处理题

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2010年8月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(4)

随笔分类

随笔档案

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜