#6791: 一直WA?!!


fagott0127 (龜)


想請問以下的code為何一直WA?
我的答案: -642277118
正確答案: 38281382169387266 
請幫我解答~謝謝囉! 
 
#include <stdio.h>

int main()
{
    int time = 0, a;
    long int b, c;
    while(scanf("%d", &time) != EOF)
    {
        for(int x = 0 ; x < time ; x++)
        {
            scanf("%d %ld %ld", &a, &b, &c);
            if(a == 1)
                printf("%ld\n", b+c);
            if(a == 2)
                printf("%ld\n", b-c);
            if(a == 3)
                printf("%ld\n", b*c);
            if(a == 4)
                printf("%ld\n", b/c);

        }
    }
    return 0;
}
#6806: Re:一直WA?!!


passerr (20130326 0340 48)


想請問以下的code為何一直WA?
我的答案: -642277118
正確答案: 38281382169387266 
請幫我解答~謝謝囉! 
 
#include

int main()
{
    int time = 0, a;
    long int b, c;
    while(scanf("%d", &time) != EOF)
    {
        for(int x = 0 ; x < time ; x++)
        {
            scanf("%d %ld %ld", &a, &b, &c);
            if(a == 1)
                printf("%ld\n", b+c);
            if(a == 2)
                printf("%ld\n", b-c);
            if(a == 3)
                printf("%ld\n", b*c);
            if(a == 4)
                printf("%ld\n", b/c);

        }
    }
    return 0;
}


我想大概是範圍太小吧

試試看

#include <stdio.h>

int main()
{
    int time = 0, a,x;
    long long int b, c;
    while(scanf("%d", &time) != EOF)
    {
        for(x = 0 ; x < time ; x++)
        {
            scanf("%d %lld %lld", &a, &b, &c);
            if(a == 1)
                printf("%lld\n", b+c);
            if(a == 2)
                printf("%lld\n", b-c);
            if(a == 3)
                printf("%lld\n", b*c);
            if(a == 4)
                printf("%lld\n", b/c);

        }
    }
    return 0;
}