标准c++,想压缩代码的来这里

P1307 [NOIP2011 普及组] 数字反转

AllureLove @ 2017-10-29 18:51:34

#include<bits/stdc++.h>//万能头文件
using namespace std;
int main()
{
    int n,sum=0;
    cin>>n;
    while(n!=0)
    {
        sum=sum*10+n%10;//升位+新来的数位
        n/=10;
    }
    cout<<sum<<endl;
    return 0;
}

by Margatroid @ 2017-10-29 20:14:43

您的压行姿势还要再学习一个

#include<bits/stdc++.h>
int main() {
    int n, sum = 0;
    std::cin >> n;
    for (; n; n /= 10) sum = sum * 10 + n % 10;
    std::cout << sum;
}

by 今A @ 2017-11-04 11:09:07

66666


by Katherineye @ 2017-11-11 10:43:32


by Chevalier @ 2018-02-25 12:06:38

6666666


by 蒟蒻lxy @ 2018-12-02 21:08:10

#include<bits/stdc++.h>
int main() 
{int n, sum = 0;std::cin >> n;for (; n; n /= 10) sum = sum * 10 + n % 10;std::cout << sum;
}

|