+ 1

Inputting ordered pairs in C++

Hello guys, Is there a way to input number like this in C++ For example: (1,2),(3,4),(5,6),(7,8),(16,188) First number in every bracket represents x coordinate and second one represents y coordinate Can I input number like that so they are read as numbers? For example something like this? <include iostream> Using namespace std; Int x[5],y[5]; Int main(){ for(int i=0;i<5;i++){ Cin>>”(x[i],y[i]),”; //I know that I can’t do this,I’m just showing what do I want } Thanks in advice!

17th Aug 2019, 9:50 PM
Slavisa
Slavisa - avatar
3 odpowiedzi
0
Nice one ~ swim ~ ! I don't see pair used too often. If you're looking for something much closer to what you wrote, you'll probably have to mess with the stream operator class or inherit from it and override it's operators.
17th Aug 2019, 10:34 PM
Zeke Williams
Zeke Williams - avatar
0
~ swim ~ sorry but I don’t get it how can I input brackets with numbers and commas using pair?
17th Aug 2019, 11:29 PM
Slavisa
Slavisa - avatar
0
pair<> is part of the Standard Template Library. You will need to include utility: #include <utility> Actually, I'm not sure about the STL thing, since <utility> was there before C++11
18th Aug 2019, 12:32 AM
Zeke Williams
Zeke Williams - avatar