C++ 代码使用命名空间运行,但不使用std::cout #包括 #包括 使用std::cout; 使用std::cin; int main() { 双度,弧度; 常数双PI=3.14159; cout度; 弧度=度*PI/180; cout
C++ 代码使用命名空间运行,但不使用std::cout #包括 #包括 使用std::cout; 使用std::cin; int main() { 双度,弧度; 常数双PI=3.14159; cout度; 弧度=度*PI/180; cout,c++,C++,setw、fixed、setprecision和left也在std名称空间中,因此您也需要使用指令为它们添加。应该是标识符声称的“未识别”的内容,但为了彻底起见?Joseph的回答是正确的,但是,是的,为了回答一个好问题,请编辑所有相关细节。 #include <iostream> #include <iomanip> using std::cout; using std::cin; int main() { double degrees, radians; c
setw
、fixed
、setprecision
和left
也在std
名称空间中,因此您也需要使用指令为它们添加。应该是标识符声称的“未识别”的内容,但为了彻底起见?Joseph的回答是正确的,但是,是的,为了回答一个好问题,请编辑所有相关细节。
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
int main()
{
double degrees, radians;
const double PI = 3.14159;
cout << "Enter an angle in degrees and I will convert it\n";
cout << "to radians for you: ";
cin >> degrees;
radians = degrees * PI / 180;
cout << degrees << " degrees is equal to ";
cout << fixed << showpoint << setprecision(4);
cout << left << setw(7) << radians << "radians.\n ";
return 0;
}