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(unsigned short isCount = -1) {
- if(cnt < isCount) {
- 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");
- int N;
- in >> N;
- in.ignore();
- Tchild children[N];
- for(int i = 0; i < N; i++) {
- Tchild child;
- getline(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(4);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement