题目:用递归法将一个整数 n 转换成字符串,例如:输入483,应输出字符串"483"。n的位数是不确定的。
问题:输出后开头多出来一个 0 ,why?
#include<iostream>
#include<string>
using namespace std;
void constest(int s)
{
int t;
char a;
if (s != 0)
constest(s / 10);
t = s % 10;
a = t + '0';
cout << a;
}
int main()
{
int s;
cout << "输入整数: ";
cin >> s;
constest(s);
}