/******************************************************************** @file main.cpp@date 2017-05-12 23:18:28@au Thor Zoro_tiger@brief Problem 1019:c Language Programming Tutorial (third Edition) After class exercise 6.9http://www.dotcpp.com/oj/problem1019.html********************************************************************/#include<cstdio>#include<cmath>#defineTEST#undefTESTintMainintargcConst Char*argv[]) {#ifdef TEST freopen ("In.txt","R", stdin); Freopen ("OUT.txt","W", stdout);#endif intHeight =0, times =0; while(SCANF ("%d%d", &height, ×)! =EOF) { DoubleLast_height = height/static_cast<Double> (POW (2.0, times));//! (A/(b^times)) DoubleTemp_height = static_cast<Double>(height); DoubleDistance =Temp_height; for(inti =1; I < times; ++i)//the process of simulating falling bounce{temp_height/=2; Distance+ = (Temp_height *2); } printf ("%.2LF%.2lf\n", last_height, distance); } return 0;}
Question 1019:c Language Programming tutorial (third Edition) after class exercise 6.9