题解 | 反向输出一个四位数
反向输出一个四位数
https://www.nowcoder.com/practice/1f7c1d67446e4361bf4af67c08e0b8b0
#include <iostream>
#include<iomanip>//包含格式化所需要的头文件
using namespace std;
int main() {
int n;
cin>>n;
int sum=0;
int b;
while (n!=0) {
b=n%10;
sum=sum*10+b;
n=n/10;
}
cout<<setw(4)<<setfill('0')<<sum<<endl;//格式化输出:宽度四,填充数字为“0",右对齐,确保为四位数
system("pause");
return 0;
}
// 64 位输出请用 printf("%lld")

腾讯音乐娱乐集团公司福利 285人发布