浮点数取整
a=3.5 包含库函数#include
ceil(a)=4 //ceil(x)返回的是大于x的最小整数。
floor(a)=3 //(floor(x)返回的是小于或等于x的最大整数)
round() //四舍五入到最邻近的整数
保留n位小数
#include
cout.setf(ios::fixed);
cout <<fixed<< setprecision(3) << a;
开方函数
#include
sqrt()
字符串输出
#include
string s;
getline(cin,s);
交换库函数
swap(a,b);
排序函数
#include
int a[n] = {5,3,1,2,4};
Sort(a,a+n);
最大值最小值 max,min
#include<windows.h>
max(a,b);
atoi()是c语言标准库的函数,用来将字符串形式的数字转为整数赋值