+ 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!
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.
0
~ swim ~ sorry but I don’t get it
how can I input brackets with numbers and commas using pair?
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