#include <iostream>
using namespace std;
int main( )
{
double a,b,c,s;
a = 3;
b=4;
c=5;
s = 1/2 * (a+b+c);
cout<<"s="<<s<<endl;
return 0;
}
为什么要把1/2改为1.0/2或者1/2.0才能得到0.5的结果
#include <iostream>
using namespace std;
int main( )
{
double a,b,c,s;
a = 3;
b=4;
c=5;
s = 1/2 * (a+b+c);
cout<<"s="<<s<<endl;
return 0;
}
为什么要把1/2改为1.0/2或者1/2.0才能得到0.5的结果
本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网