/******************************************************************** @file main.cpp@date 2017-5-9@author Zoro_ Tiger@brief Problem 1010:c Language Programming Tutorial (third Edition) after class exercise 5.8http://www.dotcpp.com/oj/problem1010.html********************************************************************/#include<cstdio>#include<cmath>#defineTEST#undefTESTintMainintargcConst Char*argv[]) {#ifdef TEST freopen ("In.txt","R", stdin); Freopen ("OUT.txt","W", stdout);#endif intBenifit =0; while(SCANF ("%d", &benifit)! =EOF) { intReward =0; if(Benifit-1000000>0) {reward+ = static_cast<int> (Benifit-1000000) *0.01f); Benifit-=1000000; } Else if(Benifit-600000>0) {reward+ = static_cast<int> (Benifit-600000) *0.015f); Benifit-=600000; } Else if(Benifit-400000>0) {reward+ = static_cast<int> (Benifit-400000) *0.03f); Benifit-=400000; } Else if(Benifit-200000>0) {reward+ = static_cast<int> (Benifit-200000) *0.05f); Benifit-=200000; } Else if(Benifit-100000>0) {reward+ = static_cast<int> (Benifit-100000) *0.075f); Benifit-=100000; } Else{reward+ = static_cast<int> (Benifit *0.1f); } printf ("%d\n", reward); } return 0;}
Question 1010:c Language Programming tutorial (third Edition) after class exercise 5.8