View Code of Problem 118

#include<stdio.h>
#include<math.h>
int main(){
	int n,j=1,m;
	float sum=5,sumx;
	while(scanf("%d",&n)!=EOF){
		if(n<=3){
			printf("Case #%d: 5\n",j);
			j++;
		}
		else if(n>3){
			for(m=n-3;m>0;m--){
				sum=sum+1.5;
			}
			sumx=round(sum);
			if(sumx<sum){
				printf("Case #%d: %.f\n",j,sumx+1);		
			}
			else if(sumx>sum){
				printf("Case #%d: %.f\n",j,sumx);
			}
			else{
				printf("Case #%d: %.f\n",j,sum);	
			}
			j++;
		}
		sum=5;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 118