我正在自学 C++,出于某种原因,即使在 std::setprecision 之后,“double”也不会打印超过 6 个有效数字。我需要做其他事情吗?如果有帮助的话,最新版本的代码块。这是所有的代码:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
std::setprecision(9);
double A = 654321.987;
cout << A << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud) #include <iostream>
using namespace std;
int main()
{
int Principal = 0;
int RetirementAge = 65;
int CurrentAge = 0;
std::cout << "What is your current age?" << std::endl;
std::cin >> CurrentAge >> std::endl;
std::cout << CurrentAge << "Is this correct?" << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它给出了“operator>>”不匹配的错误。如果有帮助,我将在代码块上使用代码块 c++ 11。