唯一的要求: 自己能看懂
#define
的使用下面会讲
-O2
时返回奇怪的东西, 开 -O2
直接 RE )namespace
-std=c++11
?double
? long double
?long long
? int
?longlong
?#define B cout << "BreakPoint" << endl;
#define O(x) cout << #x << " " << x << endl;
#define O_(x) cout << #x << " " << x << " ";
#define Msz(x) cout << "Sizeof " << #x << " " << sizeof(x)/1024/1024 << " MB" << endl;
_tp<_tyn T>void Print( T a[] , int s , int t , char sp = ‘ ‘ , char ed = ‘\n‘ ){
if( s > t ) return;
for( int i = s ; i < t ; i++ )
cout << a[i] << sp;
cout << a[t] << ed;
cout.flush();
}
_tp<_tyn T>void Print( T a , int s = 0 , int t = -1 , char sp = ‘ ‘ , char ed = ‘\n‘ ){
if( t == -1 ) t = a.size()-1;
for( int i = s ; i <= t ; i++ )
cout << a[i] << sp;
cout << ed;
cout.flush();
}
实际应用:
#include <iostream>
using namespace std;
int Popcount( int x ){
int ans = 0;
while(x){
if(x&1) ++ans;
// x >>= 1 // OMG! I FORGOT THIS!
}
// Where is the return?
}
int main(){
cout << Popcount(2333) << endl;
return 0;
}
#define B cout << "BreakPoint" << endl;
长得像函数一样...
#define O(x) cout << #x << " " << x << endl;
#x
: 输出 x
的变量名
小实验:
#define Name_Of_Var(x) cout << #x << endl;
int mrclr_akioi = 2333;
Name_Of_Var(mrclr_akioi);
#
开头的语句#ifdef INTOJ_SAIGAO
cout << "INTOJ_SAIGAO" << endl;
#endif
不会
原文:https://www.cnblogs.com/jiqimin/p/10656869.html