首页 > 编程语言 >c++ 基础语法

c++ 基础语法

时间:2022-11-13 20:11:26浏览次数:55  
标签:pb return int 基础 c++ 语法 isdigit define getchar

一眼 mophie,鉴定为:普及组。

#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define x first
#define y second
#define vi vector<int>
#define vpi vector<pii>
#define all(x) x.begin(),x.end()
#define WT int TT=read();while(TT--)
using namespace std;

inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}
inline void ckmax(int &a,int b){a=(a>b?a:b);}
inline void ckmin(int &a,int b){a=(a<b?a:b);}

vpi v;

struct node
{
	int x,y,z;
	node(int X=0,int Y=0,int Z=0){x=X,y=Y,z=Z;}
};
vector<node>v2;

signed main()
{
	v.pb({1,2});
	v.pb({3,2});
	for (auto [x,y]:v)cout<<x<<' '<<y<<'\n';
	v2.pb({1,2,3});
	node qwq(3,2,1);
	v2.pb(qwq);
	for (auto [x,y,z]:v2)cout<<x<<' '<<y<<' '<<z<<'\n';
	function<int(node,node)>add=[&](node x,node y)->int{return x.x+x.y+y.z;};
	cout<<add(v2[0],v2[1])<<'\n';
	sort(all(v2),[&](node x,node y)->bool{return x.x>x.y;});
	cout<<add(v2[0],v2[1])<<'\n';
	return 0;
}

标签:pb,return,int,基础,c++,语法,isdigit,define,getchar
From: https://www.cnblogs.com/juruo-pigstd/p/16886775.html

相关文章