Advertisement
Dzham

Untitled

Nov 18th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. using std::cout;
  6. using std::cin;
  7. using std::string;
  8.  
  9. int main() {
  10. int N, M, number;
  11. string call, name1, name2, day, month, year, name, date;
  12. std::vector<std::vector<string>> students;
  13. std::vector<string> result, print;
  14. cin >> N;
  15. for (int i = 0; i < N; i++) {
  16. cin >> name1;
  17. cin >> name2;
  18. cin >> day;
  19. cin >> month;
  20. cin >> year;
  21. name = name1 + ' ' + name2;
  22. date = day + '.' + month + '.' + year;
  23. result = { name, date };
  24. students.push_back(result);
  25. }
  26. cin >> M;
  27. for (int i = 0; i < M; i++) {
  28. cin >> call;
  29. cin >> number;
  30. if (call == "name") {
  31. if (number > 0 && number <= N) {
  32. print.push_back(students[number - 1][0]);
  33. } else {
  34. print.push_back("bad request");
  35. }
  36. } else if (call == "date") {
  37. if (number > 0 && number <= N) {
  38. print.push_back(students[number - 1][1]);
  39. } else {
  40. print.push_back("bad request");
  41. }
  42. } else {
  43. print.push_back("bad request");
  44. }
  45. }
  46. for (int i = 0; i < M; i++) {
  47. cout << print[i] << '\n';
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement