1.C++数据各类型大小和范围



2.判断数据类型的函数
typeid
如:
if (typeid(a) == typeid(int))
这个库函数typeid在头文件typeinfo.h中。
#include
3.设置精确度的函数
头文件#include
setprecision+fixed
1.只用setprecision()是精确几位
如:
double s=20.7843000
cout<
2.setprecision+fixed是小数点后精确几位
如:
double s=20.7843909,
cout<
4.万能头文件#include
若vs2017不可用参考https://blog.csdn.net/qq_43005493/article/details/86748041
5.求gcd(最大公约数)的两种方式
一、更相减损法
两个正整数a和b(a>b),它们的最大公约数等于a-b的差值c和较小数b的最大公约数。
int gcd(int a,int b){if(a==b)return a;if(a>b)return gcd(a-b,b);if(a<b)return gcd(b-a,a);}7
二、辗转相除法
两个正整数a和b(a>b),它们的最大公约数等于a除以b的余数c和b之间的最大公约数。
int gcd(int a, int b) {if (a%b == 0) {return b;}else {return gcd(b, a%b);}}
