View Code of Problem 13


int main(){
    int h,a,b,k,die,c=0;
    while(scanf("%d %d %d %d",&h,&a,&b,&k)!=EOF){
        die=0;
        if(h-a<0)			//Smash!!!一击暴命!!
            die=1;
        else{
            if(h+b*(k-1)-a*k<1)		//前k个回合已死(黑龙回血比黑龙攻击少一次)
                die=1;
            else if(a*k-b*(k+1)>0)		//前k+1个回合,黑龙在扣血
                die=1;
            else
                die=0;
        }
        if(die)
            printf("Case #%d: White win\n",++c);
        else
            printf("Case #%d: Unknow\n",++c);

    }
    return 0;
}
/*
Main.c: In function 'main':
Main.c:5:11: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
     while(scanf("%d %d %d %d",&h,&a,&b,&k)!=EOF){
           ^~~~~
Main.c:5:11: warning: incompatible implicit declaration of built-in function 'scanf'
Main.c:5:11: note: include '<stdio.h>' or provide a declaration of 'scanf'
Main.c:1:1:
+#include <stdio.h>
 
Main.c:5:11:
     while(scanf("%d %d %d %d",&h,&a,&b,&k)!=EOF){
           ^~~~~
Main.c:5:45: error: 'EOF' undeclared (first use in this function)
     while(scanf("%d %d %d %d",&h,&a,&b,&k)!=EOF){
                                             ^~~
Main.c:5:45: note: 'EOF' is defined in header '<stdio.h>'; did you forget to '#include <stdio.h>'?
Main.c:5:45: note: each undeclared identifier is reported only once for each function it appears in
Main.c:18:13: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
             printf("Case #%d: White win\n",++c);
             ^~~~~~
Main.c:18:13: warning: incompatible implicit declaration of built-in function 'printf'
Main.c:18:13: note: include '<stdio.h>' or provide a declaration of 'printf'
Main.c:20:13: warning: incompatible implicit declaration of built-in function 'printf'
             printf("Case #%d: Unknow\n",++c);
             ^~~~~~
Main.c:20:13: note: include '<stdio.h>' or provide a declaration of 'printf'
*/

Double click to view unformatted code.


Back to problem 13