Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main() {
- int n = 0;
- std::cin >> n;
- if (n <= 0) {
- std::cout << "ERROR: An array is empty.";
- return 0;
- }
- int x = 0;
- std::cin >> x;
- int cur_min_index = 0;
- int cur_min = x;
- for (int i = 1; i < n; ++i) {
- std::cin >> x;
- if (x <= cur_min) { // Последнее вхождение минимального элемента
- cur_min = x;
- cur_min_index = i;
- }
- }
- std::cout << cur_min_index;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement