?强转的差是48
#include <bits/stdc++.h> using namespace std; int main() { int t1 = 9; char t2 = 9; //int强转为char:强转成该ASCII值下的char cout << char(t1) << endl; //char强转为int:看起来相等 cout << int(t2) << endl; //想要相互之间看起来相等... char r1 = char(t1 + 48); int r2 = int(t2); cout << r1 << " " << r2; return 0; }
大小写转换的差是32
#include <bits/stdc++.h> using namespace std; int main() { //大写字母的ASCII值小 //小写字母的ASCII值大 //相差的值为 :32 char t3 = 'A'; char r3 = int(t3 + 32); cout << r3; //Console:a return 0; }
附上一张ASCII表
最后,如果你想学C/C++可以私信小编“01”获取素材资料以及开发工具和听课权限哦!