1 条题解
-
0
【例9.2】打印字符
解题思路
读入 ASCII 编码,转换为 char 后输出。
正确性说明
字符类型的数值就是其编码,类型转换得到对应字符。
易错点
不能直接输出整数编码。
复杂度
本题输入规模固定,时间 O(1),额外空间 O(1)。
参考代码(C++11)
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int x; cin >> x; cout << char(x) << "\n"; return 0; }
- 1