View Code of Problem 13

#include<stdio.h>
main()
{
	int h,a,b,k,n=1,t,i,j,m;
	while(scanf("%d",&h)!=EOF)
	{
		scanf("%d %d %d",&a,&b,&k);
		t=0;
		m=h;
			for(i=0;i<k;i++)
			{
				h=h-a;
				if(h<1)
				{
					t=1;
				}
				else 
				{
					h=h+b;
				}
			}
			h=h+b;

		if((t==1)||(h<m))printf("Case #%d: White win",n++);
		else printf("Case #%d: Unknow",n++);
	}

}

Double click to view unformatted code.


Back to problem 13