📄 cezar.cpp
字号:
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
int main(void)
{
unsigned int i,j,t;
bool temp;
char ch;
char alpfa[53];
char zapa[53];
char str[1000];
char result[1000];
do{ t=0; temp=1;
strcpy (str,"");
strcpy (result,"");
printf (" ***********MENU**********\n\n");
printf (" 1. Encoding text\n");
printf (" 2. Decoding text\n");
printf (" 3. Exit\n");
do{
printf ("\n Enter your choice: ");
ch=getche();} while ((ch!='1')&&(ch!='2')&&(ch!='3'));
if (ch=='1')
{
printf("\n");
strcpy (alpfa,"abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ");
strcpy (zapa, "defghijklmnopqrstuvwxyz abcDEFGHIJKLMNOPQRSTUVWXYZ AB");
printf (" Please enter text to code:\n\n");
} else if (ch=='2')
{
printf("\n");
strcpy (zapa, "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWYZ");
strcpy (alpfa,"defghijklmnopqrstuvwxyz abcDEFGHIJKLMNOPQRSTUVWXYZAB");
printf (" Please enter text to decode:\n\n");
} else if (ch=='3') {printf ("\n"); return 0;};
if (gets(str))
{
for (i=0; i<(strlen(str)); i++)
{ for (j=0;j<strlen(alpfa);j++)
{ if (alpfa[j]==str[i])
{
t=t+1;
result[t-1]=zapa[j];
temp=0;
}
}
if (temp!=0) {t=t+1;
result[t-1]=str[i]; temp=1;}
temp=1;
}
}
for (i=0; i<t; i++)
printf ("%c",result[i]);
printf("\n\n");
} while (1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -