0
点赞
收藏
分享

微信扫一扫

linux学习:标准IO

司马吹风 04-13 09:00 阅读 0

蓝桥杯考前准备— — c/c++

对于输入输出函数

如果题目中有要求规定输入数据的格式与输出数据的格式,最好使用scanf()prinrf()函数。

例如:输入的数据是 2020-02-18,则使用scanf("%d-%d-%d",&year,&mouth,&day)即可。

例如:输出的数据是 2020-03-02,因为有前导零的存在,所以使用printf("%d-%02d-%02d",)即可。

对于四舍五入问题

printf()函数自带有四舍五入的功能,如:printf("%.3f", 1.0235),则会输出1.024

如果我们不使用四舍五入的功能还要输出某几位数,那么我们就要自己进行设定了

如:对1.0235直接输出其小数点后3位,并且不进行四舍五入。

double r = 1.0235;
int a = (int)r;
int b = (int)((r - a) * 1000);
printf("%d.%0.3d\n",a, b);

计算三角形面积公式:

S = (x1 * y2 + x2 * y3 + x3 * y1 - y1 * x2 - y2 * x3 - y3 * x1) / 2;

要看每一个问题的数据范围,记得要检查是否有必要使用long long!!!

常用的stl容器有

#include<vector>
#include<map>
#include<set>
#include<queue>
#include<math.h>
#include<algorithm>

记得带好证件以及必要的物品!!!

举报

相关推荐

0 条评论