gpt4 book ai didi

c++ - 我不明白为什么我的文件没有写出来

转载 作者:行者123 更新时间:2023-11-28 07:25:00 26 4
gpt4 key购买 nike

#include<iostream>
#include<fstream>
using namespace std;
int main()
{

ifstream initialCost;
ofstream output;
output.open("output.txt");
initialCost.open("InitialCost.txt");
float csh1, af1, tr1, csh2, af2, tr2,tcsh1, tcsh2;

initialCost >> csh1 >> af1 >> tr1 >> csh2 >> af2 >> tr2;

tcsh1 =csh1+ (5*(csh1*tr1))+(5*af1);
tcsh2 =csh2+ (5*(csh2*tr2))+(5*af2);

cout<< "Initial House cost"<< '\t'
<< "Annual Fuel Cost" << '\t'
<< "Tax Rate" << '\t'
<< "Total Cost"<< '\n'
<< csh1 << '\t' << af1<< '\t' << tr1 << '\t' << tcsh1 << '\n'
<< csh2 << '\t' << af2<< '\t' << tr2 << '\t' << tcsh2 << '\n';



return 0;
}

我的输出很奇怪,我不明白为什么我的第二组输出不像第一组那样工作。我还需要我的输出写入输出文件。

最佳答案

改变

cout<< "Initial House cost"<< '\t'

output<< "Initial House cost"<< '\t'

关于c++ - 我不明白为什么我的文件没有写出来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18910429/

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