我需要帮助,ttlTx变量在流血事件的输出中显示为0,尽管我通过ideone传递了代码,它似乎有效,它可能是数据类型吗?帮助感激!
/*
*/
//Libraries
#include <cstdlib>
#include <iostream>
using namespace std;
//Global Constants
//Functioning Prototypes
//Execution Begins Here
int main(int argc, char **argv){
//Variables
float purchse, ttlTx, stateTx, cntyTx, total;
//Process
purchse= 52;
stateTx= 0.04; //state tax
cntyTx= 0.02; //county tax
ttlTx= purchse*(stateTx + cntyTx); //total tax
total = purchse+ttlTx;
//output
cout<<"the total tax on a $"<< purchse<<" is $"<<
ttlTx<<endl;
cout<<"which brings the total to $" << total<<endl;
//Exit Stage Right
system("PAUSE");
return EXIT_SUCCESS;
}发布于 2014-01-08 02:37:45
您粘贴的代码没有什么问题,在我的gcc编译器下,我得到:
the total tax on a $52 is $3.12
which brings the total to $55.12如预期的那样。
由于DevC++使用MinGW,所以它也使用gcc编译器,我无法想象任何大于0.1的版本会有那么严重的错误:-)
因此,这几乎肯定是某种描述的环境问题。DevC++也没有其他IDE那么活跃或受支持(虽然这是我的观点),所以我倾向于建议人们使用CygWin (如果他们不关心IDE)或代码::块 (如果他们使用)。
发布于 2014-01-08 02:36:50
你的程序很好。我觉得你的身份证出了问题。在程序中没有错误。

https://stackoverflow.com/questions/20985891
复制相似问题