Advertisement
Oslapas

Untitled

May 11th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. using namespace std;
  5. struct xy
  6. {
  7.     int x,y,nr,x1,y1;
  8. };
  9. void skaitymas(xy ma[],int &n)
  10. {
  11.     ifstream fd("kord.txt");
  12.     fd>>ma[0].x>>ma[0].y;
  13.     fd>>ma[1].x>>ma[1].y;
  14.     fd>>n;
  15.     for(int i=0;i<n;i++)
  16.     {
  17.         fd>>ma[i].nr;
  18.         for(int j=0;j<ma[i].nr;j++)
  19.         {
  20.             fd>>ma[j].x1;
  21.  
  22.         }
  23.  
  24.     }
  25.  
  26. }
  27. bool check(xy ma[],int n)
  28. {
  29.     bool a=false;
  30.     for(int i=0;i<n;i++)
  31.     {
  32.         for(int j=0;j<ma[i].nr;j++)
  33.         {
  34.             if(ma[j].x1==1)
  35.             {
  36.                 ma[0].x+=1;
  37.             }
  38.             if(ma[j].x1==3)
  39.             {
  40.                 ma[0].x-=1;
  41.             }
  42.             if(ma[j].y1==4)
  43.             {
  44.                 ma[0].x-=1;
  45.             }
  46.             if(ma[j].y1==2)
  47.             {
  48.                 ma[0].x+=1;
  49.             }
  50.             if((ma[0].x=ma[1].x)&&(ma[0].y=ma[1].y))
  51.             {
  52.                 a=true;
  53.             }
  54.         }
  55.     }
  56.     return a;
  57. }
  58. void skaiciavimas(xy ma[],int &n)
  59. {
  60.     for(int i=0;i<n;i++)
  61.     {
  62.     if(check(xy,n)==true)
  63.     {
  64.         cout<<"pasiektas tikslas"<<endl;
  65.     }
  66.     else
  67.     {
  68.         cout<<"sekos pabaiga"<<endl;
  69.     }
  70.     }
  71. }
  72. int main()
  73. {
  74.  xy ma[30];int n;
  75.  skaitymas(ma,n);
  76.  skaiciavimas(ma,n);
  77.  return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement