View Code of Problem 70

#include<stdio.h>
int main(void)
{
	long m;
	int c;
	while(scanf("%ld",&m)!=EOF)
	{
		if(m>=1000000)
		{
			c=10;
		}
		else 
		   c = m/100000;
	    switch(c)
	   {
		 case 0 : printf("%.0f\n",m*0.1); break;
		 case 1 : printf("%.0f\n",10000+(m-100000)*0.075); break;
		 case 2 :  //注意临界值
		 case 3 : printf("%.0f\n",17500+(m-200000)*0.05); break;   //case 2,3是一种计算方法
		 case 4 : 
		 case 5 : printf("%.0f\n",27500+(m-400000)*0.03); break; 
		 case 6 :
		 case 7 :
		 case 8 :
		 case 9 : printf("%.0f\n",33500+(m-600000)*0.015); break; 
		 case 10: printf("%.0f\n",39500+(m-1000000)*0.01); break;     //注意case后的形式
	   }
	}	
}

Double click to view unformatted code.


Back to problem 70