跳到正文

个人记录

语言基础

约瑟夫用脑玩约 2 分钟
原文
文章信息与版本

文章信息

收录
2026年2月6日
更新
2026年2月6日
篇幅
约 2 分钟

版本

  1. v1当前

模块复习,今天开头。

只记录自己会的,顺序不按难度。

运算

特殊(如[],(),.,->)高于单目高于双目高于赋值高于 , 。

右移用符号位补齐。

  • ==0 同 !。
  • [!=0] 同 !!。
  • !=-1 同 ~。
  • ==-1 同 !~。
  • [!=-1] 同 !!~。

数组,结构体,指针

指针:偏移&参数类型,不用动态。

STL

记得写头文件。

进阶

namespace 先进防重名。

长了 auto,要用 lambda([](){})。

decltype 好像挺有用?不用可变参。

分支

不用 switch。

循环

不用 while。

变量

short:16,int/float:32,long long/double:64

∣float∣≤3.4×1038,∣double∣≤1.7×10308|float|\le3.4\times 10^{38},|double|\le1.7\times10^{308}

语法基础

读入

C++
const int Mxxx=1e5;
inline char gc()
{
//	return getchar();
	static char buf[Mxxx],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,Mxxx,stdin),p1==p2)?EOF:*p1++;
}

输出

C++
const int Mxxx=1e5;
inline char pc(char ch,bool fl=false)
{
//	return fl?0:putchar(ch),0;
	static char buf[Mxxx],*p1=buf,*p2=buf+Mxxx;
	return (fl||((*p1++=ch)&&p1==p2))&&(fwrite(buf,1,p1-buf,stdout),p1=buf),0;
}

其他:' '=32,'\n'=10。

原文