题目链接
题目描述
读入一个四位数abcd,请你输出他的“反写”的值。
比如读入1015,输出5101;
读入4310,输出134(不能有前导零)
不合法的四位数,如234, 0123, 12412不会作为读入数据。
Input
输入一个4位数abcd
Output
输出一个4位数,表示反写的值
Sample Input
4432
Sample Output
2344
思路
定义一个整数a,输入一个整数s,则a的值为s的个位1000+s的十位100+s的百位*10+s的千位。
输出a即可。
#include<bits/stdc++.h>
using namespace std;
int main()
{
int s, a;
while(cin >> s)
{
a = s / 1000;
a += s / 100 % 10 * 10;
a += s / 10 % 10 * 100;
a += s % 10 * 1000;
cout << a << endl;
}
return 0;
}