Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  123
Language: C/C++
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 

int main(int argc, char** argv)
{
     char txt[1024];
    int choice;
 
    printf("---------------欢迎使用译码机!---------------\n");
    printf("****************************************************\n");
    printf("生成加密文字请输入1      翻译加密文字泣请输入2\n");
    printf("退出程序请输入0\n");
 
    while(1)
    {
        printf("****************************************************\n");
        printf("请输入您的选择:");
        scanf("%d",&choice);
        fflush(stdin);
        switch(choice)
        {
        case 1:
            printf("请输入文字:");
            gets(txt);
            for(int i=0;i<strlen(txt);i++)
                              {
                                   txt[i]+=1;
                              }
                              printf("生成的加密文字为:%s\n",txt);
            break;
        case 2:
            printf("请输入加密文字:");
            gets(txt);
                for(int i=0;i<strlen(txt);i++)
                                   {
                                        txt[i]-=1;
                                   }
                                   printf("解密后文字为:%s\n",txt);
            break;
        case 0:
            printf("退出成功!\n");
            exit(0);
        default:
            printf("您的输入有误,请重新输入!\n");
        }
        system("pause");
    }

     return 0;
}

Comments: