题目描述
输入一个小写字母,输出其对应的大写字母
输入输出案例
输入 q
—— 输出Q
具体实现
—— C语言
#include <stdio.h>
int main(void){
char c; // 定义字符 c
scanf("%c", &c); // 输入字符 c
printf("%c\n", char(int(c)-32));
// 简写:printf("%c\n", c-32);
return 0;
}
—— C++
#include <iostream>
using namespace std;
int main(){
char c; // 创建字符型变量
cin >> c; // 小写输入
cout << char(c-32); // 注意!!! char进行强制转换
return 0;
}
—— C++ 补充方法
#include<iostream>
#include<cctype>
#include<cstdio>
using namespace std;
int main(){
char c;
cin >> c;
putchar(toupper(c));
// putchar 用于输出一个字符(相当于强制转换 char)
// toupper 将小写字母大写对应 ASCII码输出出来
return 0;
}
—— Python
print(input().upper())
# input方法接收用户的输入
# upper方法将小写转换为大写