#12009: 請問這樣哪裡不行?我只會基礎的而已 剛學


s510306s (allen1487)


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
int a,b;
    while(scanf("%d %d",&a,&b)){
        if(a<1000000,b<1000000){
            printf("%d\n",a+b);
        }
    }

return(0);
}

#12015: Re:請問這樣哪裡不行?我只會基礎的而已 剛學


forever84721 (廖翊傑)


#include
#include
#include
int main(){
int a,b;
    while(scanf("%d %d",&a,&b)){
        if(a<1000000,b<1000000){
            printf("%d\n",a+b);
        }
    }

return(0);
}

while(scanf("%d %d",&a,&b)!=EOF)


#12025: Re:請問這樣哪裡不行?我只會基礎的而已 剛學


sos06096 (Ovuvuvuevue)


#include
#include
#include
int main(){
int a,b;
    while(scanf("%d %d",&a,&b)){
        if(a<1000000,b<1000000){
            printf("%d\n",a+b);
        }
    }

return(0);
}

while(scanf("%d %d",&a,&b)!=EOF)


int a,b;
    while(scanf("%d %d",&a,&b)){ 
        if(a<1000000,b<1000000){
            printf("%d\n",a+b); 
        } 

        break;
    }


 

如果你只想做一次的話要加break 不然while的判斷式會一直執行