Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define size 10
- int main() {
- double arr[size] = {-2, 4, -3, 5, 12, -23, -2, -234, 12, 234};
- double min = arr[0];
- double max = arr[0];
- int min_index = 0;
- int max_index = 0;
- for (int i = 1; i < size; i++) {
- if (arr[i] < min) {
- min = arr[i];
- min_index = i;
- }
- if (arr[i] > max) {
- max = arr[i];
- max_index = i;
- }
- }
- cout << "MAX: " << max << endl;
- cout << "MAX INDEX: " << max_index << endl;
- cout << "MIN: " << min << endl;
- cout << "MIN INDEX: " << min_index << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment