按照题目要求,输入是一个int型的变量,循环获取其最低位后转成字符加到字符串str中,最后输出str
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
void fun(int n)
{
string str;
while(n)
{
str += (n%10)+'0';
n /= 10;
}
cout << str << endl;
}
int main()
{
int n;
while(scanf("%d", &n) != EOF)
{
fun(n);
}
return 0;
}
京公网安备 11010502036488号