Seal_of_approval

PrVecList19A

Jul 7th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <list>
  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(list<ticket>& lottery)
  15. {
  16.     list <ticket>::iterator i;
  17.     for (i = lottery.begin(); i != lottery.end(); i++)
  18.     {
  19.         cout << left << (*i).number << " ";;
  20.         for (int j = 0; j < 7; j++)
  21.             cout << (*i).symbols[j] << " ";
  22.         cout << endl;
  23.     }
  24. }
  25.  
  26.  void move (list<ticket>& lottery, int &x)
  27.  {
  28.     list <ticket>::iterator i;
  29.     ticket t;
  30.     for (i = lottery.begin(); i != lottery.end(); i++)
  31.         if ((*i).number == x-1)
  32.         {
  33.             t = *i;
  34.             i = lottery.erase(i);
  35.             lottery.push_back(t);
  36.             break;
  37.         }
  38.  }
  39.  
  40.  void remove (list<ticket>& lottery)
  41.  {
  42.  
  43.      if (lottery.back().number % 2 == 0)
  44.          lottery.pop_back();
  45.  }
  46.  
  47. int main(void)
  48. {
  49.     ifstream in("input.txt");
  50.     list<ticket> lottery;
  51.  
  52.     int x,y;
  53.     cout << "Enter number of ticket for move ";
  54.     cin >> x;
  55.     cout << "Enter number of ticket for show ";
  56.     cin >> y;
  57.  
  58.     ticket t;
  59.     string s;
  60.     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])
  61.         lottery.push_back(t);
  62.  
  63.     remove(lottery);
  64.     move(lottery, x);
  65.     print(lottery);
  66. }
Advertisement
Add Comment
Please, Sign In to add comment