第三节 练习9
程序员文章站
2024-03-22 22:09:34
...
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<typeinfo>
using namespace std;
int main()
{
char str[] = "GSOOWFASOq";
const int len = strlen(str);
char a[len]; //???为何 +7就没bug
for(int i=0;i<=len-1;i++){
if(str[i] <=90){
if(str[i] >=88){ //到了末尾3个字母,要回首
a[len-1-i] = (int)tolower(str[i]) - 23;
}else{
a[len-1-i] = (int)tolower(str[i]) + 3;
}
}else{
if(str[i] >=120){ //到了末尾3个字母,要回首
a[len-1-i] = (int)toupper(str[i]) - 23;
}else{
a[len-1-i] = (int)toupper(str[i]) + 3;
}
}
}
cout << a;
/*char a[5] = "adsa";
cout << int(a[4]);*/
}
//cout << "输入:";