$0

打印ASCLL码题解

原题

题目大意

输入一个字符, 输出该字符的ASCLL码。

前置知识:

ASCLL码:
ASCLL码是指一个字符对应的十进制数, 作用:方便计算机通过二进制位存储字符。
ASCLL码对照表:

这里我们可以用 \(C++\) 的特性直接将字符转换成 ASCLL 码

Code

#include <iostream>
using namespace std;

char c; 

int main(){
	cin >> c;
	//方法1:
	cout << int(c) << endl;
	//方法2 
	cout << c + 0 << endl;
	return 0;
}

posted @ 2026-11-07 17:27  lyx20131111  阅读(5)  评论(0)    收藏  举报