为什么只有20分?

P1307 [NOIP2011 普及组] 数字反转

尹昕20160508 @ 2016-05-20 19:31:29

#include<iostream>
using namespace std;
int main ( ) {
    int a,b,c,m,n;
    cin>>n;
    a=n/100;
    b=n/10%10;
    c=n%10;
    m=c*100+b*10+a;
    cout<<m<<endl;
    return 0;
}

by zhuxingzhen @ 2016-05-20 20:11:26

#include <cstdio>
#include <cstring>
char a[100];
char s[100];
int main()
{
    int n;
    int i,j;
    scanf("%d",&n);
    sprintf(s,"%d",n);
    int len=strlen(s);
    for(i=0;i<=len-1;i++)
        for(j=len-i-1;j>=0;j--)
        {
            a[j]=s[i];
        }
    if(n<0)
        printf("-");
    sscanf(a,"%d",&n);
        printf("%d",n);
    return 0;
}

by CraZYali @ 2016-05-21 10:23:21

#include<iostream>
using namespace std;
int main ( ) {
    int a,b,c,m,n;
    cin>>n;
    a=n/100;
    b=n/10%10;
    c=n%10;
    cout<<c<<b<<a<<endl;
    return 0;
}//别想复杂了

by kongksora @ 2016-05-22 09:32:42

谁告诉你一定是三位数?

谁告诉你一定是正数?


by kongksora @ 2016-05-22 09:36:13

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    long long a,s=1,o,p=1;
    cin>>a;
    while(abs(a))
    {
        o=abs(a%10);
        if(a<0&&s==1)cout<<"-";
        if(o==0&&p==1);
        else{cout<<o;p=2;}
        a/=10;s++;
    }
}//麻烦了点,但是过了……

|