5m帶寬做視頻網(wǎng)站百度網(wǎng)站優(yōu)化公司
藍(lán)橋杯考前準(zhǔn)備— — c/c++
對(duì)于輸入輸出函數(shù)
如果題目中有要求規(guī)定輸入數(shù)據(jù)的格式與輸出數(shù)據(jù)的格式,最好使用scanf()
和prinrf()
函數(shù)。
例如:輸入的數(shù)據(jù)是 2020-02-18,則使用scanf("%d-%d-%d",&year,&mouth,&day)
即可。
例如:輸出的數(shù)據(jù)是 2020-03-02,因?yàn)橛星皩?dǎo)零的存在,所以使用printf("%d-%02d-%02d",)
即可。
對(duì)于四舍五入問(wèn)題
printf()
函數(shù)自帶有四舍五入的功能,如:printf("%.3f", 1.0235)
,則會(huì)輸出1.024
。
如果我們不使用四舍五入的功能還要輸出某幾位數(shù),那么我們就要自己進(jìn)行設(shè)定了
如:對(duì)1.0235
直接輸出其小數(shù)點(diǎn)后3位,并且不進(jìn)行四舍五入。
double r = 1.0235;
int a = (int)r;
int b = (int)((r - a) * 1000);
printf("%d.%0.3d\n",a, b);
計(jì)算三角形面積公式:
S = (x1 * y2 + x2 * y3 + x3 * y1 - y1 * x2 - y2 * x3 - y3 * x1) / 2;
要看每一個(gè)問(wèn)題的數(shù)據(jù)范圍,記得要檢查是否有必要使用long long!!!
常用的stl容器有
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<math.h>
#include<algorithm>