View Code of Problem 13

#include <stdio.h>
#include <stdlib.h>

int main()
{

    int h,a,b,k,i,j;
    j=1;
    while(scanf("%d%d%d%d",&h,&a,&b,&k)!=EOF)
    {
    for(i=0;i<k;i++)
    {
        h=h-a;
        if(h<=0)
        {
            printf("Case #%d: White win\n",j);
            j++;
            break;
        }
        else
        {
            h=h+b;
        }

    }
    if(h>0)
    {
        printf("Case #%d: Unknow\n",j);
        j++;
    }
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 13