TwITe

Untitled

Aug 15th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.88 KB | None | 0 0
  1. void lesson7() {
  2.     map <string, string> dictionary;
  3.     int n;
  4.     cin >> n;
  5.     for (int i = 0; i < n; i++) {
  6.         string key, value;
  7.         cin >> key >> value;
  8.         dictionary[key] = value;
  9.     }
  10.     string search_word;
  11.     cin >> search_word;
  12.     for (auto i : dictionary) {
  13.         if (i.second == search_word) {
  14.             cout << i.first;
  15.         }
  16.         if (i.first == search_word) {
  17.             cout << i.second;
  18.         }
  19.     }
  20. }
  21.  
  22. void lesson6() {
  23.     set <int> numbers_one;
  24.     int n;
  25.     cin >> n;
  26.     for (int i = 0; i < n; i++) {
  27.         int value;
  28.         cin >> value;
  29.         numbers_one.insert(value);
  30.     }
  31.     set <int> numbers_two;
  32.     int m;
  33.     cin >> m;
  34.     for (int i = 0; i < m; i++) {
  35.         int value;
  36.         cin >> value;
  37.         numbers_two.insert(value);
  38.     }
  39.     vector <int> common_numbers;
  40.     for (auto i = numbers_one.begin(); i != numbers_one.end(); i++) {
  41.         if (numbers_two.find(*i) != numbers_two.end()) {
  42.             common_numbers.push_back(*i);
  43.         }
  44.     }
  45.     for (auto i : common_numbers) {
  46.         cout << i << " ";
  47.     }
  48. }
  49.  
  50. void lesson5() {
  51.     set <int> numbers_one;
  52.     int n;
  53.     cin >> n;
  54.     for (int i = 0; i < n; i++) {
  55.         int value;
  56.         cin >> value;
  57.         numbers_one.insert(value);
  58.     }
  59.     set <int> numbers_two;
  60.     int m;
  61.     cin >> m;
  62.     for (int i = 0; i < m; i++) {
  63.         int value;
  64.         cin >> value;
  65.         numbers_two.insert(value);
  66.     }
  67.     int count = 0;
  68.     for (auto i : numbers_one) {
  69.         if (numbers_two.find(i) != numbers_two.end()) {
  70.             count++;
  71.         }
  72.     }
  73.     cout << count;
  74. }
  75.  
  76. void lesson4() {
  77.     set <int> numbers;
  78.     int n;
  79.     cin >> n;
  80.     for (int i = 0; i < n; i++) {
  81.         int value;
  82.         cin >> value;
  83.         if (numbers.find(value) == numbers.end()) {
  84.             cout << "NO" << endl;
  85.         }
  86.         else {
  87.             cout << "YES" << endl;
  88.         }
  89.         numbers.insert(value);
  90.     }
  91. }
  92.  
  93. void lesson3() {
  94.     set <int> numbers;
  95.     int n, count = 0;
  96.     cin >> n;
  97.     for (int i = 0; i < n; i++) {
  98.         int value;
  99.         cin >> value;
  100.         if (numbers.find(value) == numbers.end()) {
  101.             count++;
  102.         }
  103.         numbers.insert(value);
  104.     }
  105.     cout << count;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment