#include<iostream>
#include<iomanip>
//#include<string>
using namespace std;
void main(){
int i=123,j=456;
while(i!=0){
char a=char(i%10);
i/=10;
cout<<a<<setw(4);
cout<<a-'0'<<setw(4);
cout<<a+'0'<<setw(10);
}
cout<<endl;
while(j!=0){
char b=j%10+48;
char c=j%10+'0'; //字符转换为数字 int i=c-‘0’;
j/=10;
cout<<setw(4)<<b<<setw(4)<<c;
}
cout<<endl;
//system("pause");//cin.get();//如果是单个提取字符串,注意结尾是'/0',加上cin.ignore();
//getchar(); //此处避免执行完程序自动退出
}
1.a-‘0’是字符与字符的ASCII相加减的结果,即ASCII码的差值
2.字符b,c将数字转化为字符,但不改变其输出形式。字符a将数字转化为ASCII码对应的字符。