//---------------------------------------------------------------------------
/****************************************************************************
練習5-2:寫一個程式計算球體的體積,4/3πr3。 *
****************************************************************************/
#include <iostream>
//---------------------------------------------------------------------------
float r;
const float PI = 3.1415926;
int main(int argc, char* argv[])
{
std::cout << "Enter the radius value of ball:";
std::cin >> r;
std::cout << "The ball's valume is(4/3πr3):" << 4.0/3.0 * PI * (r*r*r)
<< '\n';
std::system("pause");
return 0;
}
//---------------------------------------------------------------------------
題目來源:C++風格與藝術 第二版 Steve Oualline 著 黃吉霈 編譯
答案來源:自我撰寫(不保證正確喔)
留言列表