【发布时间】:2014-01-18 20:44:15
【问题描述】:
好的,所以我很新而且没有经验,所以这个问题很可能很愚蠢,但我试图查找解决方案但失败了,所以我想我会在这里尝试为什么不。
我正在尝试编写一个程序,它获取三角形的边并输出面积、周长以及它是否是直角三角形。周界工作正常,但是当我尝试定义 s 和区域时,它给了我错误消息“调用的对象'int'不是函数或函数指针”
这是我的代码:
#include <iostream>
#include <cmath>
using namespace std;
//area = sqrt(s(s-a)(s-b)(s-c))
int main()
{
int a;
int b;
int c;
int perimeter;
int area;
int s;
//ask for triangle sides
cout << "Input triangle sides (smallest to largest) " << endl;
cin >> a >> b >> c;
perimeter = a + b + c;
s =(a+b+c)/2;
area = sqrt(s(s-a)(s-b)(s-c))
//This one says 'Expression is not assignable' I don't see why it wouldn't work...
if ((c*c)-((a*a)+(b*b))= 0 )
cout << "Right triangle" << endl;
cout << "Side A: " << a << endl;
cout << "Side B: " << b << endl;
cout << "Side C: " << c << endl;
cout << "The perimeter is " << perimeter << endl;
cout << "The area is " << area << endl;
return 0;
}
任何帮助将不胜感激。谢谢!
【问题讨论】:
-
你知道
=vesus==的区别吗?