美文网首页
杭电OJ-1048(凯撒密码)

杭电OJ-1048(凯撒密码)

作者: 小可爱你要快快长大 | 来源:发表于2017-04-22 16:51 被阅读115次
    #include<stdio.h>
    #include<string.h>
    
    int main(){
        char str[200],str1[200];
        int x,i,j,m;
        char a[200];
        while(gets(str)){
        if(strcmp(str,"START")==0){
            while(gets(str1)){
                if(strcmp(str1,"END")==0)
                    break;
                else{
                i=0;
                m=strlen(str1);
                for(j=0;j<m;j++){
                    if((str1[j]>=65)&&(str1[j]<=90))
                        str1[j]=(str1[j]-65+21)%26+65;
                    a[i]=str1[j];
                    i++;
                }
                for(x=0;x<i;x++)
                    printf("%c",a[x]);
                printf("\n");
                }
            }
        }
        else{
            if(strcmp(str,"ENDOFINPUT")==0)
                break;
        }
        }
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:杭电OJ-1048(凯撒密码)

          本文链接:https://www.haomeiwen.com/subject/eqvszttx.html