标签:ota rod man fan sage operator answer end his
This passage is wrote to introduce the header file <iomanip>.
The basic usage of the library funcions from this header file is in the form of "."or by add function after the "<</>>" operator.
Let‘s see some forms about it:
#include <iostream> #include <iomanip> using namespace std; int main(){ int n=16; double f=3.1415926535; cout<<setbase(8)<<n<<endl;//you can set the input/output system(jin_zhi)by the setbase(); cout<<setbase(10)<<n<<endl; cout<<setbase(16)<<n<<endl;//you can change the case by uppercase a->A; cin>>setbase(16)>>n; //by this way you can easily transform short size input and output; cout<<setbase(10)<<n<<endl; //it‘s the same if you use"dec/hex/oct"; //set the significant digits,it will round off at the same time
// ps.you can round off by int(n+0.5); cout<<setprecision(2)<<f<<endl; //set the total decimal digits; cout<<fixed<<setprecision(6)<<f<<endl; //set the alignment(dui_qi_fang_shi); cout<<setw(10)<<left<<1<<endl;//set width cout<<setw(10)<<right<<1<<endl; //show the dot and zero; cout<<showpoint<<3.1200<<endl; //scientific form of numbers; //it will change the form entirely since it‘s used and I don‘t know how to turn off it...... cout<<scientific<<f<<endl; }
After you learned so much,you can practice by this question below.
S:calculate the area of the circle and output the answer in the round to seven decimal places
........
Let‘s forget about the code. :D
标签:ota rod man fan sage operator answer end his
原文地址:https://www.cnblogs.com/lym11248/p/12773540.html