C++中的位宽与保留小数
一、setw函数
C++ setw() 函数用于设置字段的宽度,语法格式如下
setw(n)
比如:
#include <bits/stdc++.h> using namespace std; int main () { cout<<setw(6)<<23; return 0; }二、字符填充setfill
上面是用空格填充的,可以指定某些字符进行填充。
#include <bits/stdc++.h> using namespace std; int main () { int x=23; cout << setfill('#') << setw(6) <<x<< endl; return 0; }效果:
三、保留小数setprecision
#include <bits/stdc++.h> using namespace std; int main () { double value = 3.14159; cout << fixed << setprecision(2) << value << endl; return 0; }.jztagtree{max-height:85vh;right:0px}.jzDown{top:10vh}.jztagtree li a{background-color:#448EF6}.jztagtree li a:before{border-right:10px solid #448EF6}.jztagtree li a:hover{background:#0045a6}.jztagtree li a:hover::before{border-right:10px solid #0045a6}
$("#jztoc").toc({content: ".single", headings: "h1,h2,h3"});