跳到正文

题解

B2017 打印ASCII码 题解

zmza约 1 分钟
原文
文章信息与版本

文章信息

发布
2021年7月3日
收录
2026年11月29日
更新
2026年11月29日
篇幅
约 1 分钟
获赞
21
题目
B2017

版本

  1. v1当前

题目要我们输出一个字符 ASCII 码,怎么做呢?

ASCII 码,就是字符对应的数字。

所以我们可以将字符强制转换成 int 型,再输出。

代码:

C++
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a;
	cin >> a;
	cout << (int)a;
	return 0;
}
原文
抓取于
  1. Budy

    这就过了

  2. Budy

    #include <stdio.h> int main(){ printf("%d",getchar()); }

  3. Budy

    #include <stdio.h> int main(){ printf("%d",getchar()); }

  4. Budy

    #include <stdio.h> int main(){ printf("%d",getchar()); }

  5. 小小小蒟蒻

    %%% zmzDALAO下凡了!!!