C++学习注意点
1.cin,cout关同步再用,不然效率很糟cin,cout关同步再用,不然效率很糟cin,cout关同步再用,不然效率很糟。重要的事情说三遍。关同步代码:std::ios::sync_with_stdio(false);
2.判断相等是==是==是==。我就因为这个卡了好多次。
3.给数组整体赋初值:memset(a,0,sizeof(a)); 头文件为string.h或memory.h
4.文件操作 freopen("xx.in","r",stdin); freopen("xx.out","w",stdout); 头文件为cstdio
5.读入BT优化:
const int MAXN = 10000000;
const int MAXS = 60*1024*1024;
int numbers[MAXN];
char buf[MAXS];
void fread_analyse()
{
freopen("data.txt","rb",stdin);
int len = fread(buf,1,MAXS,stdin);
buf[len] = '/0';
analyse(buf,len);}
6.STL中快排什么的定义">"或"<"号,其实都一样
bool cmp(int a,int b)
{
return a>b;
}
7.关于带stable_的函数和不带的
带有stable的函数可保证相等元素的原本相对次序在排序后保持不变
8.各种各样的头文件
#include
//STL 通用算法
#include//STL 位集容器
#include
#include
#include
#include
#include//复数类
#include
#include
#include
#include
#include//STL 双端队列容器
#include//异常处理类
#include
#include//STL 定义运算函数(代替运算符)
#include
#include//STL 线性列表容器
#include
#include
#include//基本输入/输出支持
#include//输入/输出系统使用的前置声明
#include
#include//基本输入流
#include//基本输出流
#include//STL 队列容器
#include//STL 集合容器
#include//基于字符串的流
#include//STL 堆栈容器
#include//标准异常类
#include//底层输入/输出支持
#include//字符串类
#include//STL 通用模板类
#include//STL 动态数组容器
#include
#include