总结

输出语句

#include<bits/stdc++.h>

printf("%.2f",a*b/10.0);

getline(cin,s);

printf("%5d",i);

指定要打印的参数类型为整数,并指定字段宽度为5个字符。

scanf("%d:%d",&a,&b);

  1. %5d:这表示打印一个整数,并且至少占据5个字符的宽度。如果整数的位数不足5位,则在左侧用空格填充。

  2. %-5d:这也是打印一个整数,但是加了一个减号表示左对齐,至少占据5个字符的宽度。如果整数的位数不足5位,则在右侧用空格填充。

  3. %05d:这表示打印一个整数,并且至少占据5个字符的宽度。如果整数的位数不足5位,则在左侧用0填充。

  4. %.2f:这表示打印一个浮点数,保留两位小数。如果小数位数不足两位,则用0填充。

  5. %.0f:这也是打印一个浮点数,但是.0f表示不保留小数,即四舍五入到整数。

  • isupper函数用于检测字符是否为大写字母,如果是大写字母则返回非零值,否则返回0。

  • islower函数用于检测字符是否为小写字母,如果是小写字母则返回非零值,否则返回0。

  • isdigit(a[i])用于检测是不是数字

  • lower_bound()

  • bindary_search()

  • upper_bound()

  • 字符 ‘1’ 对应的ASCII码是 49

  • 字符 ‘a’ 对应的ASCII码是 97

  • 字符 ‘A’ 对应的ASCII码是 65

to_string()

常用头格式:

#define x first
#define y second
using namespace std;
typedef long long LL;
typedef pair<LL,int> PII;
unordered_map<int,PII>um;

for(i=a.begin();i!=a.end();i++)

结构体排序

自定义排序

s.find("chi1 huo3 guo1")!=-1

去重操作,里面是一个迭代器

s.erase(unique(a.begin(),a.end()),a.end());

bool cmp(int &a,int &b){

​ return a>b;

}

sort(s,s+n,cmp);

priority_queue<int,vector,greater>pq;

struct xx{

​ double a,b,c;

}s[1005];

bool cmp(xx x,xx y){

​ return x.a<y.a;

}

seta[55];

a[i].insert(x);

a[i].find(j)!=a[i].end();

#include<bits/stdc++.h>

sets;

s.erase(x);

auto &i=s.lower_bound(x);

if(i!=s.end())

STL

map

键值从小到大开始排

clear()函数

count

stack

top()

pop()

vector

reverse

sort

a.erase(unique(a.begin(), a.end()), a.end());

queue

最小堆:小的在前面

std::priority_queue<int, std::vector, std::greater> minHeap;

list

set

insert

find()

erase()

clear

unique

set::iterator i=s.lower_bound(x);

算法

二分

并查集

int find(int x){
if(a[x]!=x)a[x]=find(a[x]);
return a[x];
}