竞赛中经常使用的C++写法
2024-09-28 06:23:38
首先是构造函数,重载
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#define maxn 65540
using namespace std; struct Node
{
int x,y;
Node (int x = 0,int y = 0):x(x),y(y) {} //构造函数
};
Node operator + (const Node& a,const Node& b)
{
return Node(a.x+b.x,a.y+b.y);
}
ostream& operator << (ostream &out,const Node& p) //重载流输出方式
{
out<<"("<<p.x<<","<<p.y<<")";
return out;
}
int main()
{
Node a,b(1,2);
Node c = a+b;
cout<<a+b<<endl;;
}
最新文章
- Appium移动自动化框架
- Web Api中的get传值和post传值
- Git连接Github
- oracle的表名、字段名、constraint名的长度限制分别是多少?
- Android 一个Activity保存它自己的实例
- CC ANUMLA(STL的运用)
- glusterfs快速安装
- xmlplus 组件设计系列之八 - 分隔框(DividedBox)
- shell-输入与输出<;echo, read, cat, tee >;
- windows :config windows update &hellip; 一直处于假死状态
- React项目中实现右键自定义菜单
- 文本分类TextCNN
- java_19List 集合
- java集合框架联系小图
- 【idea】清除类中无用的包
- python中的ljust、rjust
- [THUSC2017]巧克力[斯坦纳树、随机化]
- Anti-Forgery Request Recipes For ASP.NET MVC And AJAX
- JAVA GUID
- Python 安装pytz
热门文章
- luogu P3393 逃离僵尸岛-搜索剪枝+spfa
- POJ 2349 Arctic Network(贪心 最小生成树)
- ubuntu修改apt-get源为国内镜像源
- pycharm配置git--图文教程
- zoj 1240
- MySQL数据库不识别server=.而是识别localhost
- 『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]CF-236B. Easy Number Challenge
- UVA 11090 判负圈问题
- bzoj1190 [HNOI2007]梦幻岛宝珠 动态规划
- springboot注释详解