我需要一个以“比率”开头的行的建议......它不是在编译 [英] I need a suggestion for the the line that starts with "ratio"... it's not compiling

查看:74
本文介绍了我需要一个以“比率”开头的行的建议......它不是在编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以比率开头的以下程序行应该=

5√M/ m 

其中M是maxSpeedRpm和m minSpeedRpm。请帮忙,我正试图解决这个问题。













 #include< iostream> 
#include< cmath>
using namespace std;
int
main0()
{
int maxSpeedRpm,minSpeedRpm;
双倍比率;

cout<< 以每分​​钟转数输入最大速度;
cin>> maxSpeedRpm;
cout<< 以每分​​钟转数输入最低速度;
cin>> minSpeedRpm;

比率= sqrt((pow(maxSpeedRpm / minSpeedRpm),(1/5)));

cout<< 计算的比率是<<比;

cin.ignore();
cin.get();
返回0;
}

解决方案

如果你穿插一些空白,你可以自己看看它为什么不编译:

 ratio = sqrt((pow(maxSpeedRpm / minSpeedRpm),(1/5))); 



所以你得了括号错了。你可能想写:

 ratio = sqrt(pow((maxSpeedRpm / minSpeedRpm), 0  2 )); 


pow()函数有两个参数...如下所示

c ++,cmath

  double  pow( double   base  double  exponent); 
long double pow( long double base long double exponent);
float pow( float base float exponent);
double pow( double base int exponent);
long double pow( long double base int exponent);







谢谢

Asp.Net C#帮助博客 [ ^ ]


The following program line that starts with "ratio" is supposed to =

5√M/m

where M is maxSpeedRpm and m minSpeedRpm. Please help, I am going cross eyed trying to work this out.






#include <iostream>
#include <cmath>
using namespace std;
int
main0()
{
    int maxSpeedRpm, minSpeedRpm;
    double ratio;
    
    cout << "Enter the maximum speed in revolutions per minute";
    cin >> maxSpeedRpm;
    cout << "Enter the minimum speed in revolutions per minute";
    cin >> minSpeedRpm;
    
    ratio = sqrt((pow(maxSpeedRpm/minSpeedRpm),(1/5)));

    cout << "The calculated ratio is" << ratio;
       
    cin.ignore();
    cin.get();
    return 0;
}

解决方案

If you intersperse some blanks you can see for yourself why it doesn''t compile:

ratio = sqrt( (pow(maxSpeedRpm/minSpeedRpm), (1/5)) );


So you got the parenthese wrong. You probably meant to write:

ratio = sqrt (pow ((maxSpeedRpm/minSpeedRpm), 0.2));


pow() function having two arguments...as below
c++ , cmath

double pow (      double base,      double exponent );
long double pow ( long double base, long double exponent );
      float pow (       float base,       float exponent );
     double pow (      double base,         int exponent );
long double pow ( long double base,         int exponent );




Thanks
Asp.Net C# Help Blog[^]


这篇关于我需要一个以“比率”开头的行的建议......它不是在编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆