View Code of Problem 13

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

Double click to view unformatted code.


Back to problem 13