Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5. struct robot{
  6. int x;
  7. int y;
  8. };
  9. void wypisz(robot *wsk, int nn)
  10. {
  11.     for(int i=0; i<nn; i++)
  12.     {
  13.         cout<<wsk[i].x <<" "<<wsk[i].y<<endl;
  14.     }
  15. }
  16.  
  17. int main()
  18. {
  19.    string nazwa;
  20.    cin>>nazwa;
  21.    fstream plikin;
  22.     plikin.open(nazwa.c_str(), ios::in);
  23.     if(!plikin)
  24.     {
  25.         cout<<"brak";
  26.         return 0;
  27.  
  28.     }
  29.     int a;
  30.     plikin>>a;//nasze "n"
  31.     robot *robocik=new robot[a];
  32.     for(int i=0; i<a; i++)
  33.     {
  34.         plikin>>robocik[i].x;
  35.         plikin>>robocik[i].y;
  36.     }
  37.     wypisz(robocik, a);
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement