需要一些修复表面积和横向面积
Need some fixing SurfaceArea and LateralArea
嗨,伙计们,我需要一些帮助修复一个基本的c++程序。SurfaceArea
和LateralArea
都有误差。错误如下....
被调用的对象类型'int'不是函数或函数指针
对二进制表达式('double'和'double')无效的操作数
我的代码如下....
#include <iostream>
using namespace std; //allows me to use cout and cin w/o typing std in the main
int main(int argc, const char * argv[])
{
double height; //initialzing my variables
double bottombase;
double topbase;
double volume;
double LateralArea;
double SurfaceArea;
cout << "Please type in the height: "; //asking users for information in order to find volume, and surface area
cin >> height;
cout << "Please type in the length of one side of the bottom base: ";
cin >> bottombase;
cout << "Please type in the length of one side of the top base: ";
cin >> topbase;
volume = height * bottombase * topbase;
cout << "Your volume is: " << volume << endl;
LateralArea = 2(bottombase + topbase) * sqrt(((bottombase-topbase)/2)^2 + height^2);
SurfaceArea = LateralArea1 + bottombase^2 + topbase^2;
cout << "Your surface area is: " << SurfaceArea << endl;
return 0;
}
不能省略乘法运算符,所以2(bottombase + topbase)
是错的,需要是2 * (bottombase + topbase)
。此外,^
操作符并不像您想象的那样。在c++中,它是位异或,很可能不是你想的那样。c++中没有幂运算符,所以如果你必须取某项的平方,比如x
,你应该显式地执行x * x
,或者使用pow
函数:pow(x, 2)
。你需要#include <cmath>
来使用pow
相关文章:
- 我的前横向如何混乱
- 横向C 中的结构误差数组
- c++,如何在删除重复项的同时横向链表
- 什么是横向指针转换
- 横向浏览嵌套地图
- 矢量迭代器在横向卷轴射击游戏中不可取消引用
- 横向约简操作的名称
- 出于某种原因,横向上的数组无法正常工作
- c++sfml横向加载映射
- 在Qt中将应用程序方向锁定为横向
- 使用算术记数法横向排列一串字符
- 表面积/体积
- std::istringstream iss(std::move(string));越过初始化,尽管它是横向循环
- 从上到下横向打印BST
- 用C++计算球体的体积和表面积
- MoSync 3.3.1,横向屏幕方向导致崩溃
- 二叉搜索树 序横向递归函数无法正常工作
- 需要一些修复表面积和横向面积
- 如何执行与将Windows 7显示从横向更改为纵向相同的操作