为什么只有20分?C++大神求教

P1307 [NOIP2011 普及组] 数字反转

Powill @ 2017-08-03 14:22:34

#include<cstdio>
using namespace std;
int main()
{
    int m,n,a,b,c;
    scanf("%d",&m);
    a=m%100%10;
    b=(m%100-a)/10;
    c=(m-a-b)/100;
    n=a*100+b*10+c;
    printf("%d\n",n);
    return 0;
} 
求救

by 大主宰 @ 2017-08-08 18:57:30

题目里没说一定是三位数


by 囧人232 @ 2017-08-09 22:26:33

n的范围


by 江湖高圣哲 @ 2017-08-13 00:19:46

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    int S=0;
    int a=0;
    int T=0;
    scanf("%d",&N);
    if(N<0) 
    {
        N=0-N; 
        T=1;
    }
    for (int i=0;i<10;i++) 
    {
        int b=N/10; 
        a=N-b*10;
        N=N/10;
        S=S+a;
        S=S*10;
        if (N<10)
        {
            a=N;
            S=S+a;
            break;
        }
    }
    if(T==1)
    {
        S=0-S;
    }
    printf("%d\n",S);
    return 0;
}

|