我们都在努力的活着~
2025-12-20 10:55:43
发布于:浙江
不是,这我手不得打废。
全部评论 3
不用写那么多判断,12行代码搞定(我以前考试就是这道题,我if了148行,记忆犹新)
3天前 来自 浙江
0呵呵呵。
3天前 来自 浙江
0哪来的148行?
3天前 来自 浙江
0
何意味
3天前 来自 上海
0???
3天前 来自 浙江
0
原代码:
#include<iostream>
using namespace std;
int main(){
char a;
cin >> a;
if (a=='a')cout<<"A";
else if (a == 'b') cout << "B";
else if (a == 'c') cout << "C";
else if (a == 'd') cout << "D";
else if (a == 'e') cout << "E";
else if (a == 'f') cout << "F";
else if (a == 'g') cout << "G";
else if (a == 'h') cout << "H";
else if (a == 'i') cout << "I";
else if (a == 'j') cout << "J";
else if (a == 'k') cout << "K";
else if (a == 'l') cout << "L";
else if (a == 'n') cout << "N";
else if (a == 'm') cout << "M";
else if (a == 'o') cout << "O";
else if (a == 'p') cout << "P";
else if (a == 'q') cout << "Q";
else if (a == 'r') cout << "R";
else if (a == 's') cout << "S";
else if (a == 't') cout << "T";
else if (a == 'u') cout << "U";
else if (a == 'v') cout << "V";
else if (a == 'w') cout << "W";
else if (a == 'x') cout << "X";
else if (a == 'y') cout << "Y";
else if (a == 'z') cout << "Z";
else if (a == 'A') cout << "a";
else if (a == 'B') cout << "b";
else if (a == 'C') cout << "c";
else if (a == 'D') cout << "d";
else if (a == 'E') cout << "e";
else if (a == 'F') cout << "f";
else if (a == 'G') cout << "g";
else if (a == 'H') cout << "h";
else if (a == 'I') cout << "i";
else if (a == 'J') cout << "j";
else if (a == 'K') cout << "k";
else if (a == 'L') cout << "l";
else if (a == 'N') cout << "n";
else if (a == 'M') cout << "m";
else if (a == 'O') cout << "o";
else if (a == 'T') cout << "t";
else if (a == 'U') cout << "u";
else if (a == 'V') cout << "v";
else if (a == 'W') cout << "w";
else if (a == 'X') cout << "x";
else if (a == 'Y') cout << "y";
else if (a == 'Z') cout << "z";
return 0;
}
简化代码:
#include <iostream>
using namespace std;
int main() {
char ch;
cin >> ch;
cout << char(ch ^ 32) << endl;
return 0;
}3天前 来自 浙江
0是个人物
3天前 来自 浙江
0???
3天前 来自 浙江
0?
3天前 来自 浙江
0



















有帮助,赞一个