返回列表 發帖

【課堂練習】面積計算 - 圓面積

圓面積的計算公式如下:
圓面積 = 半徑 x 半徑 x 3.14

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float x;
  7.     cout<<"輸入圓的半徑(公分): ";
  8.     cin>>x;
  9.     cout<<"半徑"<<x<<"公分的圓,面積為"<<x*x*3.14<<"平方公分."<<endl;
  10.     system("pause");
  11.     return 0;
  12. }
複製代碼

TOP

本帖最後由 陳品諺 於 2023-6-5 20:50 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float r;
  7.     cout << "輸入圓的半徑(公分): " ;
  8.     cin >> r;
  9.     cout << "半徑" << r << "公分的圓,面積為" << r*r*3.14 << "平方公分." << endl;
  10.     system("pause");
  11.     return 0;
  12. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float x;
  7.         cout<<"請輸入圓形的半徑(公分):";
  8.         cin>>x;
  9.         cout<<"半徑"<<x<<"公分的圓,面積為"<<x*x*3.14<<"平方公分"<<endl;
  10.         system("pause");
  11.         return0;   
  12. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float x,y;
  7.     cout<<"請輸入圓的半徑 ";
  8.     cin>>x;
  9.     cout<<"半徑"<<x<<"公分的圓,面積為"<< x*x*3.14<<"平方公分."<<endl;
  10.     system("pause");
  11.     return 0;  
  12. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float x;
  7.     cout<<"輸入圓的半徑(公分):";
  8.     cin>> x;
  9.     cout<<"半徑"<<x<<"公分的圓,面積為"<<x*x*3.14<<"平方公分."<<endl;
  10.     system("pause");
  11.     return 0;
  12. }
複製代碼

TOP

本帖最後由 陳姿瑜 於 2023-5-30 20:33 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float r;
  7.     cout<<"請輸入圓的半徑(公分)";
  8.     cin>>r;
  9.     cout<<"半徑為"<<r<<"公分的圓,面積為"<<r*r*3.14<<"平方公分"<<endl;
  10.     system("pause");
  11.     return 0;
  12.     }
複製代碼

TOP

本帖最後由 王閎民 於 2023-5-30 20:32 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float p=3.14;
  7.     float r;
  8.     cout<<"請輸入圓半徑(cm): ";
  9.     cin >>r;
  10.     cout<<"半徑為"<<r<<"的圓形面積為: "<<r*r*p<<"平方公分"<< endl;
  11.     system("pause");
  12.     return 0;
  13. }
複製代碼
回復 1# 陳育霖

TOP

  1. <iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float x,y;
  7.     cout<<"請輸入圓形的半徑(公分): ";
  8.     cin>>x;
  9.     cout<<"請輸入圓形的半徑(公分): ";
  10.     cin>>y;
  11.     cout<<"半徑"<<x<<"公分,半徑"<<y<<"公分的圓形,面積為"<<x*y*3.14<<"平方公分."<<endl;
  12.     system("pause");
  13.     return 0;
  14. }
複製代碼

TOP

本帖最後由 孟涵 於 2023-5-30 21:00 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float x;
  7.     cout<<"請輸入圓半徑(公分): ";
  8.     cin>>x;
  9.     cout<<"半徑為"<<x<<"的圓面積為: "<<x*x*3.14<<"平方公分" <<endl;

  10.     system("pause");
  11.     return 0;
  12. }
複製代碼

TOP

回復 1# 陳育霖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float x, y;
  7.     cout<<"請輸入半徑(公分): ";
  8.     cin>>x;
  9.     cout<<"底"<<x<<"公分;,面積為"<<(x*x)*3.14<<"平方公分."<<endl;
  10.     system("pause");
  11.     return 0;
  12. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         float r;
  7.         cout<<"pis input the radius of the circle";
  8.         cin>>r;
  9.         cout<<"if the radius of the circle is "<<r<<",then the area of the circle should be "<<r*r<<" times pai\n"<<"which is about "<<r*r*3.1415;

  10.         system("pause");
  11.         return 0;
  12. }
複製代碼

TOP

  1. #include<iostream>  
  2. #include<cstdlib>  
  3. using namespace std;  
  4. int main ()  //主程式
  5. {
  6.     float a; //a是半徑
  7.     cout << "輸入圓的半徑(cm): ";
  8.     cin >> a;
  9.     cout << "半徑" << a << "公分的圓,面積為" << a * a * 3.14 << "平方公分" << endl;
  10.     system("pause");
  11.     return 0 ; //回傳主控台
  12. }
複製代碼

TOP

返回列表