当前位置:网站首页>004: print characters
004: print characters
2022-07-21 22:38:00 【Long Xingchen】
004: Print character
Total time limit :
1000ms
Memory limit :
65536kB
describe
Enter a ASCII code , Output corresponding characters .
Input
An integer , That is character. ASCII code , Ensure that there are corresponding visible characters .
Output
a line , Contains the corresponding characters .
The sample input
65
Sample output
A
in the meantime , I accidentally missed this problem , Now let me make up for it again
In fact, this question and 003 It's the same , Can be cast (c++ Coercion is allowed ), We used to be char Variable to int Variable , Is it just the opposite now , We are int Variable to char Variable , because c++ There are two input and output methods in , One is printf, The other is cout, So we can divide it into two ways .
Code 1 :
#include <iostream> // Header file call
using namespace std;
int main()
{
char a; // Set up char Type variable a
int b; // Set up int Type variable b
cin>>b; // Input int Type variable n
a=(char)b; // take int Type variable b Cast to char The type variable is assigned in char Type variable a On the body
cout<<a<<endl; // Output char Type variable a
return 0; // The return value is 0
}
Such thing cout Output input
Code 2 :
#include <iostream> // Header file call
using namespace std;
int main()
{
char a; // Set up char Type variable a
int b; // Set up int Type variable b
scanf("%d",&b); // Input int Type variable n
a=(char)b; // take int Type variable b Cast to char The type variable is assigned in char Type variable a On the body
printf("%c\n",a); // Output char Type variable a
return 0; // The return value is 0
}
Of course , In some compilers, coercion can be used , such , We don't need to add a bracket .
Code three :
#include<iostream>
using namespace std;
int main()
{
char X;
int y;
cin>>y;
X=y;
cout<<X<<endl;
return 0;
}
Now? , I've filled up the problems I missed before , If you want to know ASCII code , You can read my article in detail “003: Print ASCII code ”.http://t.csdn.cn/h3OpQhttp://t.csdn.cn/h3OpQ 004: Print character ( complete )
边栏推荐
- Chat about matter protocol (original chip protocol)
- Why is Le Xin in a hurry to release esp32-c3 when there are few words
- 第十周ACM训练报告
- 328. 奇偶链表
- Using UUID as MySQL primary key, my boss broke up
- datart 数据可视化作品开源 | 图表插件作品全开源啦,通过百度云下载链接提取
- 148. 排序链表
- 堪比“神仙打架”的开源数据可视化社群,你见过吗?
- Heap - principle to application - heap sorting, priority queue
- Let you know the current situation and future development trend of wireless charging technology
猜你喜欢
What is the gateway? What is the Internet of things gateway?
流批一体?实时数据处理场景化应用实例~
机器学习-频率派vs贝叶斯派
What impact does the Internet of things have on the development of enterprises?
Vs2019+opencv installation and configuration tutorial
概率论-方差和协方差、相关系数
归并排序
datart 数据可视化作品开源 | 图表插件作品全开源啦,通过百度云下载链接提取
Deep analysis of fiboracci sequence
并发开篇——带你从0到1建立并发知识体系的基石
随机推荐
Pytorch2onnx2tensorflow environment preparation win10
企业如何做好数据管理?产品选型怎么做?
In depth analysis of multiple knapsack problem (Part 2)
手把手教你在服务器上用YOLOv4训练和测试数据集(保姆级)
第十周ACM训练报告
In depth analysis of ArrayList source code, from the most basic capacity expansion principle, to the magic iterator and fast fail mechanism, you have everything you want!!!
74. 搜索二维矩阵
Built in WiFi and Bluetooth chip of Flathead brother xuantie
概率论-假设检验
The 22 pictures show you in-depth analysis of prefix, infix, suffix expressions and expression evaluation
In depth analysis of multiple knapsack problem (Part 1)
Let you know the current situation and future development trend of wireless charging technology
庖丁解牛斐波拉契数列和背包问题——详细解析两个问题优化过程,带你从最基本的问题看懂动态规划!!!
数据可视化图表插件开发作品大赏(一)
轻松自制PASCAL VOC数据集
299. 猜数字游戏
In depth analysis of multiple knapsack problem (Part 2)
03-selenium的自动化测试模型
Teach you how to use Charles to grab bags
一文讲透,分布式系统的数据分片难题