从键盘上输入一个字符,进行加密以后再输出在屏幕上。用C++

2024-12-15 11:26:20
推荐回答(1个)
回答1:

//转换
char Convert1(char ch)
{
char res;
if(ch <= 'z' && ch >= 'a')
{
res = 'Z' - (ch - 'a');
}
else if( ch <= 'Z' && ch >= 'A')
{
res = ch + ch/2 + (ch%2?1:0);
}
else if( ch <= '9' && ch >= '0')
{
res = ch + ch/10;
}
return res;
}

void main()
{

char szData[] = "abc9A";
for (int i = 0; i < strlen(szData); i++)
{
printf("(%c, %c)", szData[i], Convert1(szData[i]));
}

return;

}