点击打开链接 #include<iostream> #include<string> using namespace std; void main(){ int n,t,i=0; cin >> n; char s[100]; while (n != 0){ t = n % 10; n = n / 10; s[i++] =t+'0';//将整数赋值给字符 } s[i] = '\0'; cout << s << endl; system("pause"); }