Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <iostream>
- #include <time.h>
- using namespace std;
- void main()
- {
- srand(time(NULL));
- const int size = 20;
- int arr[size] = {};
- int in = 0, in2 = 0;
- int max = arr[0], min = arr[0];
- for (int i = 0; i < size; i++)
- {
- arr[i] = -13 + rand() % 27;
- if (max < 0)
- {
- max = arr[i];
- in = i;
- }
- if (min > arr[i])
- {
- min = arr[i];
- in2 = i;
- }
- }
- for (int i = 0; i < size; i++)
- {
- cout << "index" << "[" << i << "] " << arr[i] << "\n";
- }
- cout << "Max " << max << " index " <<"[" <<in << "]" << endl;
- cout << "Min " << min << " index " << "[" << in2 << "]";
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement