Advertisement
cyberjab

Untitled

Nov 29th, 2022
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <string>
  6. #include <vector>
  7. #include <set>
  8. #include <ctime>
  9.  
  10. using namespace std;
  11.  
  12. int cnt_before_min(vector <int> sp) {
  13.     int cnt, mn = 10e5;
  14.     for (int i = 0; i < sp.size(); i++) {
  15.         if (sp[i] < mn) {
  16.             mn = sp[i];
  17.             cnt = i;
  18.         }
  19.     }
  20.     return cnt;
  21. }
  22.  
  23. int main() {
  24.     time(NULL);
  25.     vector <int> u1, u2;
  26.     for (int i = 0; i < 25; i++) u1.push_back(rand() % 201 - 100);
  27.     for (int i = 0; i < 30; i++) u2.push_back(rand() % 201 - 100);
  28.     for (int i = 0; i < 25; i++) {
  29.         cout << u1[i] << " ";
  30.     }
  31.     cout << endl;
  32.     cout << cnt_before_min(u1) << endl;
  33.     for (int i = 0; i < 30; i++) {
  34.         cout << u2[i] << " ";
  35.     }
  36.     cout << endl;
  37.     cout << cnt_before_min(u2);
  38.     return 0;
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement