可以直接输入结构体,顺便初始化;
#include<bits/stdc++.h>
using namespace std;
struct node
{
int x, y, z;
friend istream & operator >> (istream&, node &t)
{
cin >> t.x >> t.y;
t.z = 1; //顺便初始化z
return cin;
}
friend ostream & operator << (ostream &, node &t)
{
cout << t.x << ' ' << t.y << ' ' << t.z << endl;
return cout;
}
};
int main()
{
node t;
cin >> t;
cout << t;
}