Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. // Points.cpp : Defines the entry point for the console application.
  2. // Ćwiczenia str. 349
  3.  
  4. #include "stdafx.h"
  5. #include "../../../../std_lib_facilities.h"
  6.  
  7. struct Point {
  8. int x;
  9. int y;
  10. Point()
  11. :x(0), y(0) {}
  12. };
  13.  
  14. ifstream& operator>>(ifstream& ist, Point& p);
  15.  
  16. ofstream& operator<<(ofstream& ist, Point& p);
  17.  
  18. istream& operator>>(istream& ist, Point& p);
  19.  
  20. ostream& operator<<(ostream& ist, Point& p);
  21.  
  22. int main()
  23. {
  24. vector<Point> points;
  25. Point p;
  26.  
  27. cout << "Podaj 7 par wspolrzednych:\n";
  28. int seven_pairs = 16;
  29. cin >> p;
  30. for (int i = 0; i < seven_pairs; ++i)
  31. points.push_back(p);
  32. }
  33.  
  34. istream& operator>>(istream& ist, Point& p)
  35. {
  36. int x, y;
  37. char ch1, ch2, ch3;
  38. ist >> ch1 >> x >> ch2 >> y >> ch3;
  39. if (!ist) return ist;
  40. if (ch1 != '(' || ch2 != ',' || ch3 != ')') // Błąd formatu.
  41. {
  42. ist.clear(ios_base::failbit);
  43. return ist;
  44. }
  45. p = Point(x, y);
  46. return ist;
  47. }
  48.  
  49. //ostream& operator<<(ostream& ist, Point& p)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement