Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <list>
- #include <algorithm>
- #include <fstream>
- using namespace std;
- struct ticket
- {
- int number;
- int symbols[7];
- };
- void print(list<ticket>& lottery)
- {
- list <ticket>::iterator i;
- for (i = lottery.begin(); i != lottery.end(); i++)
- {
- cout << left << (*i).number << " ";;
- for (int j = 0; j < 7; j++)
- cout << (*i).symbols[j] << " ";
- cout << endl;
- }
- }
- void move (list<ticket>& lottery, int &x)
- {
- list <ticket>::iterator i;
- ticket t;
- for (i = lottery.begin(); i != lottery.end(); i++)
- if ((*i).number == x-1)
- {
- t = *i;
- i = lottery.erase(i);
- lottery.push_back(t);
- break;
- }
- }
- void remove (list<ticket>& lottery)
- {
- if (lottery.back().number % 2 == 0)
- lottery.pop_back();
- }
- int main(void)
- {
- ifstream in("input.txt");
- list<ticket> lottery;
- int x,y;
- cout << "Enter number of ticket for move ";
- cin >> x;
- cout << "Enter number of ticket for show ";
- cin >> y;
- ticket t;
- string s;
- 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])
- lottery.push_back(t);
- remove(lottery);
- move(lottery, x);
- print(lottery);
- }
Advertisement
Add Comment
Please, Sign In to add comment