標籤:under .cpp har fine 過程 static bsp code scan
/********************************************************************@file Main.cpp@date 2017-05-12 23:18:28@author Zoro_Tiger@brief 問題 1019: C語言程式設計教程(第三版)課後習題6.9 http://www.dotcpp.com/oj/problem1019.html********************************************************************/#include <cstdio>#include <cmath>#define TEST#undef TESTint main(int argc, const char* argv[]){#ifdef TEST freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);#endif int height = 0, times = 0; while (scanf("%d%d", &height, ×) != EOF) { double last_height = height / static_cast<double>(pow(2.0, times)); //! (a/(b^times)) double temp_height = static_cast<double>(height); double distance = temp_height; for (int i = 1; i < times; ++i) //!類比落下彈起的過程 { temp_height /= 2; distance += (temp_height * 2); } printf("%.2lf %.2lf\n", last_height, distance); } return 0;}
問題 1019: C語言程式設計教程(第三版)課後習題6.9