返回列表 發帖

面積計算 (一) - 三角形

三角形的面積公式:底*高/2
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int len=0;
  7.     int wid=0;
  8.     cout<<"請輸入底"<<endl;
  9.     cin>>len;
  10.    
  11.     cout<<"請輸入高"<<endl;
  12.     cin>>wid;
  13.    
  14.      cout<<"等於"<<len*wid/2<<endl;
  15.    
  16.      system("pause");
  17.     return 0;   
  18. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int len;
  7.     int wid;
  8.     cout<<"請輸入底(公分):"<<endl;
  9.     cin>>len;
  10.     cout<<"請輸入高(公分):"<<endl;
  11.     cin>>wid;
  12.     cout<<"此三角形面積是"<<len*wid/2<<"平方公分"<<endl;
  13.     system("pause");   
  14.     return 0;
  15. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int gro=0;
  7.     int hig=0;
  8.     cout<<"請輸入 底:"<<endl;
  9.     cin>>gro;
  10.     cout<<"請輸入 高:"<<endl;
  11.     cin>>hig;
  12.     cout<<"面積是:"<<gro*hig/2<<endl;
  13.     system ("pause");
  14.     return 0;
  15. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6. int len=0;
  7. int wid=0;
  8. cout<<"請輸入底"<<endl;
  9. cin>>len;   
  10. cout<<"請輸入高"<<endl;
  11. cin>>wid;
  12. cout<<"等於"<<len*wid/2<<endl;
  13. system("pause");   
  14. return 0;     
  15. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int len;
  7.     int wid;
  8.     cout<<"請輸入 底:"<<endl;
  9.     cin>>len;
  10.     cout<<"請輸入 高:"<<endl;
  11.     cin>>wid;
  12.     cout<<" 底*高/2:"<<len*wid/2 <<endl;  
  13.     system("pause");
  14.     return 0;
  15. }
複製代碼

TOP

返回列表