Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- using std::cout;
- using std::cin;
- using std::string;
- int main() {
- int N, M, number;
- string call, name1, name2, day, month, year, name, date;
- std::vector<std::vector<string>> students;
- std::vector<string> result, print;
- cin >> N;
- for (int i = 0; i < N; i++) {
- cin >> name1;
- cin >> name2;
- cin >> day;
- cin >> month;
- cin >> year;
- name = name1 + ' ' + name2;
- date = day + '.' + month + '.' + year;
- result = { name, date };
- students.push_back(result);
- }
- cin >> M;
- for (int i = 0; i < M; i++) {
- cin >> call;
- cin >> number;
- if (call == "name") {
- if (number > 0 && number <= N) {
- print.push_back(students[number - 1][0]);
- } else {
- print.push_back("bad request");
- }
- } else if (call == "date") {
- if (number > 0 && number <= N) {
- print.push_back(students[number - 1][1]);
- } else {
- print.push_back("bad request");
- }
- } else {
- print.push_back("bad request");
- }
- }
- for (int i = 0; i < M; i++) {
- cout << print[i] << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement