精确到小数点后几位怎么做

cout精确小数点:

//需要导入库文件

cout<<setprecision(n)<<PI<<endl;//这里n指需要精确到的位数

 

printf精确小数点:

printf("%.n",&PI)//n也指需要精确的位数

posted @ 2021-07-28 13:39  out-man  阅读(316)  评论(0)    收藏  举报