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