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