Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- class Tchild {
- public:
- string name, toys[10];
- int b_year, cnt;
- public:
- void print() {
- cout << name << "(" << b_year << "): ";
- for (int i = 0; i < cnt; i++) {
- if (i != 0)cout << ", ";
- cout << toys[i];
- }
- cout << '.' << endl;
- }
- bool has_toy(string check_toy) {
- for(string toy : toys) {
- if(toy == check_toy)
- return true;
- }
- return false;
- }
- };
- int main() {
- setlocale(LC_ALL, "Russian");
- ifstream in("input.txt"), in2("toy.txt");
- int N;
- in >> N;
- Tchild children[N];
- for (int i = 0; i < N; i++) {
- Tchild child;
- in >> child.name;
- in >> child.b_year;
- in >> child.cnt;
- in.ignore();
- for (int j = 0; j < child.cnt; j++) {
- getline(in, child.toys[j]);
- }
- children[i] = child;
- }
- for (Tchild child : children) {
- child.print();
- }
- string check_toy;
- getline(in2, check_toy);
- for(Tchild child : children) {
- if(child.has_toy(check_toy))
- cout << child.name << ' ';
- }
- return 0;
- }
- /*
- 2
- Ренат
- 2008
- 3
- Плюшевый мишка
- Футбольный мячик
- Brawlstars
- Матвей
- 2009
- 2
- Шахматы
- Brawlstars
- */
- /*Brawlstars*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement