#include #include using namespace std; //保留2位小數 int main(){ double x=123.456; double y=3.14159; double z=-3214.67; cout<<setiosflags(ios::fixed)<<seti... ...
#include <iostream> #include <iomanip> using namespace std; //保留2位小數 int main(){ double x=123.456; double y=3.14159; double z=-3214.67; cout<<setiosflags(ios::fixed)<<setiosflags(ios::right)<<setprecision(2); cout<<setw(10)<<x<<endl; cout<<setw(10)<<y<<endl; cout<<setw(10)<<z<<endl; return 0; }