Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <algorithm>
- #include <cmath>
- #include <string>
- #include <vector>
- #include <set>
- #include <ctime>
- using namespace std;
- int cnt_before_min(vector <int> sp) {
- int cnt, mn = 10e5;
- for (int i = 0; i < sp.size(); i++) {
- if (sp[i] < mn) {
- mn = sp[i];
- cnt = i;
- }
- }
- return cnt;
- }
- int main() {
- time(NULL);
- vector <int> u1, u2;
- for (int i = 0; i < 25; i++) u1.push_back(rand() % 201 - 100);
- for (int i = 0; i < 30; i++) u2.push_back(rand() % 201 - 100);
- for (int i = 0; i < 25; i++) {
- cout << u1[i] << " ";
- }
- cout << endl;
- cout << cnt_before_min(u1) << endl;
- for (int i = 0; i < 30; i++) {
- cout << u2[i] << " ";
- }
- cout << endl;
- cout << cnt_before_min(u2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement