//26+(字母)-1即a->z,b->y,因为一共26个字母
#include<iostream>
using namespace std;
int main()
{
char a[100];
int n = 0;
cin.getline(a, 100);
while (a[n] != 0)
{
n++;
}
for (int i = 0; i < n; i++)
{
if (a[i] >= 'a'&&a[i] <= 'z')
{
a[i] = 'z' - (a[i] - 'a');
}
if (a[i] >= 'A'&&a[i] <= 'Z')
{
a[i] = 'Z' - (a[i] - 'A');
}
}
for (int i = 0; i < n; i++)
{
cout << a[i];
}
cout << endl;
system("pause");
return 0;
}
字符转换 如 a->26+a-1即a->z
最新推荐文章于 2020-12-28 18:45:26 发布