[問題] 海龍公式
剛學C++
學長出了一個作業_海龍公式
本人寫完後發現有點問題
回傳值的問題
但是不知道要怎麼解決通常不是可以在
int main()的()中寫上函數嗎?
有點不太懂這部份
不知道這種問題在這邊可不可以問?
如果不行問的話會自D
#include<iostream>
#include<cmath>
using namespace std;
double a,b,c,s,area;
int math()
{
cout<<"Please input the three values for the lengths of the sides of a
triangle."<<endl<<"a=";
cin>>a;
cout<<"b=";
cin>>b;
cout<<"c=";
cin>>c;
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
}
int main(int math)
{
if(a+b>c&&a+c>b&&b+c>a)
cout<<"The lengths cannot be those of the sides of a triangle."<<endl;
else
cout<<"The areaof the triangle is "<<area<<endl;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.57.78.163
→
09/18 18:51, , 1F
09/18 18:51, 1F
就是我寫了一個程式,但是他跑不出來,出現了ERROR
說是回傳值不正確,於是我想說會不會是這邊錯了int main(int math)
※ 編輯: diana76 來自: 61.57.78.163 (09/18 18:56)
→
09/18 18:58, , 2F
09/18 18:58, 2F
恩阿!不知道能不能幫我跑跑看,到底是哪裡出了問題XD
※ 編輯: diana76 來自: 61.57.78.163 (09/18 19:01)
→
09/18 19:03, , 3F
09/18 19:03, 3F
推
09/18 19:06, , 4F
09/18 19:06, 4F
推
09/18 19:34, , 5F
09/18 19:34, 5F
→
09/18 20:55, , 6F
09/18 20:55, 6F
推
09/18 21:11, , 7F
09/18 21:11, 7F
推
09/18 21:13, , 8F
09/18 21:13, 8F
→
09/18 21:21, , 9F
09/18 21:21, 9F
→
09/19 00:33, , 10F
09/19 00:33, 10F
→
09/19 00:33, , 11F
09/19 00:33, 11F
推
09/19 01:19, , 12F
09/19 01:19, 12F
→
09/19 11:40, , 13F
09/19 11:40, 13F
推
09/20 00:13, , 14F
09/20 00:13, 14F
→
09/20 11:20, , 15F
09/20 11:20, 15F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章