gpt4 book ai didi

c++ - 在 C++ 中打印百分比

转载 作者:太空狗 更新时间:2023-10-29 20:28:09 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
C++ int float problem

我只是想计算并打印一个百分比,虽然计算中使用的变量显示正确,但最终百分比一直显示为“0”。这是代码:

 int iWageredTot = iBet * 4 * iGames;
cout<<"Total Won: "<<iBankRoll<<endl;
cout<<"Wagered total: "<<iWageredTot<<endl;
float iPercent;
iPercent = iBankRoll / iWageredTot;
cout<<iPercent<<"% edge\n"<<endl;

这是输出:

Total won: -770
Wagered Total: 4000
0% edge

我尝试使用 int、float 和 double。我错过了什么?感谢您的帮助。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com