这是我的代码:
#include <iomanip>
#include <fstream>
#include <iostream>
using namespace std;
int main ()
{
ifstream fin;
fin.open("Celsius.txt");
if (!fin.good()) throw "I/O error";
double myC;
fin >> myC;
fin.close();
ofstream fout;
fout.open("Fahrenheit.txt");
if (!fout.good()) throw "I/O error";
double myAnswer = (myC * 1.80) + 32;
fixed;
cout << myC << " Celsius equals " << setprecision(3) << myAnswer << " Fahrenheit" << endl;
fout << myC << " Celsius equals " << setprecision(3) << myAnswer << " Fahrenheit" << endl;
fout.close();
}
好的,我只是缺少一些完整的基本神经元吗,我似乎在理解这一点上有一些障碍。
- 对于格式化的输入回显,它是 -2,并且
- -2 表示不使用一位十进制数字格式化输出。
不要只格式化输入值输出。
fixed; cout << myInput << " should not be formatted, but " << setprecision(3) << myOutput << " should be" << endl;
那不是留下来吗:
myInput 是未格式化的输入回显,而 myOutput 被格式化为一位十进制数字?