C++ 計數程式 (10點)

2009-12-17 3:55 am
它寫了:
An example of the cout statement for display 2 data items is shown below;
cout<<"Area is"<<area<<endl;
cout<<"Circumferece is"<<circumference;

Applying above statemen,write a program to calculate the circulate the circumference and area of a circle with radius=2 and pi=3.14(ans. area=12.56,
circumference=12.56)

有誰做做好人幫我解答呢?有10點回報,謝謝
更新1:

第一位好心人: 你的資料寫住: Source file not complied. 請你再次給我一個好的答案,謝謝!!

回答 (1)

2009-12-17 10:59 pm
✔ 最佳答案
please check following code


#include

using namespace std;

main( ){
int iRadius = 2;
const double cdPi = 3.14;

double area = iRadius * iRadius * cdPi;
double circumference = iRadius * 2 * cdPi;

cout << "Area is " << area << endl;
cout << "Circumference is " << circumference << endl;
}

2009-12-18 10:21:41 補充:
每次 post 都會不見了一點。
#include 要加

還有,你是用甚麼來 compile,我用 dev c++ 來 compile是可以的。
另外,你是否完全不懂 c++ ?

2009-12-18 10:28:34 補充:
看來真是沒辦法,怎樣都 post 不了。你嘗試看看下面網站的例子。
http://www.hitmill.com/programming/cpp/helloWorld.htm
http://www.cplusplus.com/doc/tutorial/program_structure/


收錄日期: 2021-04-24 10:44:59
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20091216000051KK01289

檢視 Wayback Machine 備份