5m帶寬做視頻網站百度網站優(yōu)化公司
藍橋杯考前準備— — c/c++
對于輸入輸出函數
如果題目中有要求規(guī)定輸入數據的格式與輸出數據的格式,最好使用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>