#include <iostream> #include <iomanip> #include <bitset> using namespace std; int main() { double n = 3.1415926;
#include <iostream> #include <iomanip> using namespace std; int main() { int n; cin >> n; cout.setf(ios::showbase); cout << "十进制:" << n << endl; cout.unsetf(ios::dec); cout.setf(ios::oct); cout << "八进制:" << n << endl; cout.unsetf(ios::oct); cout.setf(ios::hex); cout << "十六进制:" << n << endl; return 0; }
#include <iostream> #include <iomanip> #include <string> using namespace std; int main() { double n = 3.1415926; cout.setf(ios::internal); cout.precision(8); cout << n << endl; cout.precision(6); cout << n << endl; cout.precision(4); cout << n << endl; return 0; }
cout << setiosflags(ios::fixed) << setprecision(8) << n << endl; cout << setiosflags(ios::fixed) << setprecision(6) << n << endl; cout << setiosflags(ios::fixed) << setprecision(4) << n << endl; cout << bitset<2>(n) << endl; return 0; }
标签:std,13,main,cout,int,namespace,2023,include From: https://www.cnblogs.com/xuxingkai/p/17398419.html