首页 > 解决方案 > 表达式不能用作函数:错误

问题描述

#include<iomanip>
#include<cmath>
using namespace std;

int main()
{
double lenght;
lenght=(3(sqrt(3)/2))*(pow(2,2));

return length;
}

为什么我收到错误:表达式不能用作函数

标签: c++

解决方案


您忘记了*表达式中的运算符3(sqrt(3)/2))

另外,由于您的main函数是 type intreturn (int)lenght;

#include<iomanip>
#include<cmath>
using namespace std;

int main()
{
    double lenght;
    lenght = (3*(sqrt(3) / 2)) * (pow(2, 2));
    

    return (int)lenght;
}

推荐阅读