PAT(Basic Level) Practice : 1011,1012

1011

## 不同变量类型能装下多大的数字
#include <cstdio>;
long long A;
scandf("%lld",&A);

在实际使用中,long和int都是4个字节。long long是8个字节。

1012

控制数字的精度

使用setprecision()函数,它的头文件是 iomanip

#include <iomanip>

自动补零

cout.setf(ios::fixed);
cout << fixed<< setprecision(2) << a <<endl; 

关闭补零

cout.unsetf(ios::fixed);
cout << fixed<< setprecision(2) << a <<endl; 

注意:setf那一行不能省略

posted @ 2020-09-17 15:16  韩天尊  阅读(64)  评论(0)    收藏  举报