Created
May 31, 2022 20:33
-
-
Save ChrisVilches/2734de57b3bfb30e3e262e66935d02af to your computer and use it in GitHub Desktop.
How to print and read custom data in C++.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
struct Point { | |
int x, y; | |
}; | |
ostream& operator<<(ostream& os, const Point& p) { | |
return os << "(" << p.x << ", " << p.y << ")"; | |
} | |
istream& operator>>(istream& is, Point& p) { return is >> p.x >> p.y; } | |
int main() { | |
Point a, b; | |
cin >> a >> b; | |
cout << a << endl; | |
cout << b << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment