备战蓝桥杯 Day1 回顾语言基础
开启蓝桥杯刷题之路
Day1 回顾语言基础
1.配置dev
工具->编译选项->勾选编译时加入以下命令->设定编译器配置(release和debug)都要->
-std=c++11
->代码生成/优化->代码生成/优化->语言标准(-std)->ISO C++11
->代码警告->显示最多警告信息(-Wall)->Yes
->连接器->产生调试信息->Yes
2.输入输出
ios::sync_with_stdio(false);
cin.tie(0);
用cout<<“\n”
,不用cout<<endl
3.模版
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
return 0;
}
4.数组
const int N=1e5+9;
int a[N];
5.typedef
typedef long long ll;
ll a[N];
6.string
#include <string>
string s;
getline(cin,s);
其他的见[[String]]
7.sort函数
见[[排序#1.sort()]]
8.最值查找
min(),max(),min_element(),max_element,nth_element()
max_element可用于数组(max_element(a,a+n))或者vector(max_element(a.begin(),a.end())),返回地址*max_element
才是元素值,获取数组索引int pos=max_element-a
9.二分查找
binary_search(),lower_bound(),upper_bound()
10.大小写转换
islowerchar ch(),isupper(char ch),tolower(char ch),toupper(char ch)
65(‘A’)-90(‘Z’)
97(‘a’)-122(‘z’)
ch-‘A’+‘a’(upper->lower)
11.其他库函数
(1)swap()
(2)reverse()
(3)unique()
12. STL
13.memset
给数组赋初值0
memset(a,0,sizeof(a));