Advertisement
Guest User

Стратегия контрольная

a guest
Jan 17th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. //
  2. //  main.cpp
  3. //  STRATEGY
  4. //
  5. //  Created by Андрей Москалёв on 17.01.17.
  6. //  Copyright © 2017 Андрей Москалёв. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <vector>
  11.  
  12. using namespace std;
  13.  
  14. int main(int argc, const char * argv[]) {
  15.     int a_from, a_to, b_from, b_to, cnt = 0;
  16.     cin >> a_from >> a_to >> b_from >> b_to;
  17.     int minimum = min(min(a_from, a_to), min(b_from, b_to));
  18.     int maximum = max(max(a_from, a_to), max(b_from, b_to));
  19.     vector <int> a(maximum + 1, 0);
  20.     for (int i = min(a_from, a_to); i <= max(a_from, a_to); ++i) ++a[i];
  21.     for (int i = min(b_from, b_to); i <= max(b_from, b_to); ++i) ++a[i];
  22.     for (int i = minimum; i <= maximum; ++i) {
  23.         if (a[i] > 1) ++cnt;
  24.     }
  25.     cout << cnt;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement