我竟然忘记了输入,导致WA,我太粗心了,下次一定不会再犯
#include<iostream>
using namespace std;
int main()
{
char a;
cin >> a;
char ans = a + 'A' - 'a';
cout << ans;
}
看看大佬
python
print(input().upper())
# 转换大小写函数
cctype函数
#include<iostream>
#include<cctype>
#include<cstdio>
using namespace std;
int main(){
char a;
cin>>a;
putchar(toupper(a));//putchar输出一个字符(相当于强制转换char),toupper则是将小写字母大写对应ASCII码输出出来
return 0;//我是不怎么习惯用return 0的
}
使用getchar简化
#include<cctype>
#include<cstdio>
int main(){
putchar(toupper(getchar()));
return 0;
}