返回列表 發帖

[作業] 正方形面積計算機

讓使用者指定正方形的邊長, 算出正方形的面積.

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

TOP

1.#inciude<iostream>

2.using namespace std;

3.int main()

4.{

5.  float x;

6.  cout<<"<正方形面積計算機>"<<endl;

7.  cout<<"請輸入邊(公分):";

8.  cin>>x;

9.  cout<<endl;

10.  cout<<"公分的正方形,面積為"<<(x*x)<<"平方公分.<<endl;

11.  system("pause");

12.  return 0;

13.}

TOP

1.#inciude<iostream>

2.using namespace std;

3.int main()

4.{

5.  float x;

6.  cout<<"<正方形面積計算機>"<<endl;

7.  cout<<"請輸入邊(公分):";

8.  cin>>x;

9.  cout<<endl;

10.  cout<<"公分的正方形,面積為"<<(x*x)<<"平方公分.<<endl;

11.  system("pause");

12.  return 0;

13.}

TOP

#include<iostream>

using namespace std;

int main()

{
  int x;  
   
  int y;  

  cout<<"長方形面積計算機"<<endl;
  
  cout<<endl;

  cout<<"請輸入長(公分):";

  cin>>x;

  cout<<endl;

  cout<<"請輸入寬(公分):";

  cin>>y;

  cout<<endl;
  
  cout<<"長方形面積為"<<(x*y)<<"平方公分"<<endl;
  
  cout<<endl;

  system("pause");

  return 0;

}

TOP

返回列表