为什么是50分呢

P1307 [NOIP2011 普及组] 数字反转

wOshiWo @ 2017-01-31 23:49:06

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int i,l,a, k = 0, w[11];
    long j,n,fn=0;
    scanf("%d", &n);
    for (i=1; (n/i) != 0;i=i*10)
        k = k + 1;//求这个数有多少位
    memset(w, 0, sizeof(w));
    j = n;
    for (i = k; i >0; i--)
    {
        a = (int)pow(10, i - 1);
        l = j / a;
        j = j % a;
        w[i] = l;
    } //把每位数字放入数组中
    for (i=k,a=1;i>0;i--)
    {
        fn = fn + w[a] * ((int)pow(10, i - 1));
        a++;
    } //反转数字
    printf("%d\n",fn);
    return 0;
}

by wOshiWo @ 2017-01-31 23:57:18

我懂了

scanf("%d", &n);

printf("%d\n",fn);

这两句格式应为%ld

不用再回了


|