Advertisement
Seal_of_approval

PrVecList19B

Jul 7th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <fstream>
  6. using namespace std;
  7.  
  8. struct ticket
  9. {
  10.     int number;
  11.     int symbols[7];
  12. };
  13.  
  14.  void print(vector<ticket>& lottery)
  15. {
  16.     for (int i = 0; i < lottery.size(); i++)
  17.     {
  18.         cout << "Num" << left << lottery[i].number << " ";;
  19.         for (int j = 0; j < 7; j++)
  20.             cout << lottery[i].symbols[j] << " ";
  21.         cout << endl;
  22.     }
  23. }
  24.  
  25.  void show (vector<ticket>& lottery, int &y)
  26.  {
  27.     ticket t;
  28.     for (int i = 0; i < lottery.size(); i++)
  29.     {
  30.         t = lottery[i];
  31.         if (t.number == y)
  32.         {
  33.             cout << "Ticket vice versa: Num" << t.number << " " << t.symbols[6] << t.symbols[5] << t.symbols[4] << t.symbols[3] << t.symbols[2] << t.symbols[1] << t.symbols[0] << endl;
  34.             break;
  35.         }
  36.     }
  37.  }
  38.  
  39.  void move (vector<ticket>& lottery, int &x)
  40.  {
  41.     ticket t;
  42.     for (int i = 0; i < lottery.size(); i++)
  43.     {
  44.         t = lottery[i];
  45.         if (t.number == x)
  46.         {
  47.             lottery.erase(lottery.begin()+i);
  48.             lottery.push_back(t);
  49.             break;
  50.         }
  51.     }
  52.  }
  53.  
  54. int main(void)
  55. {
  56.     ifstream in("input.txt");
  57.     vector<ticket> lottery;
  58.    
  59.     int x,y;
  60.     cout << "Enter number of ticket for move ";
  61.     cin >> x;
  62.     cout << "Enter number of ticket for show ";
  63.     cin >> y;
  64.  
  65.     ticket t;
  66.     string s;
  67.     while(in >> t.number >> t.symbols[0] >> t.symbols[1] >> t.symbols[2] >> t.symbols[3] >> t.symbols[4] >> t.symbols[5] >> t.symbols[6])
  68.         lottery.push_back(t);
  69.  
  70.     show(lottery, y);
  71.     move(lottery, x);
  72.     print(lottery);
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement