Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <time.h>
- #include <iostream>
- using namespace std;
- const int size = 20;
- void monitor(int *);
- ////////////////////////////////////////////////////
- int main()
- {
- int arr[size] = {10, 11, 22, 3, 44, 75, 86, 997, 8, 99,
- 0, 1, 2,13, 4, 5, 6, 97, 28, 19};
- srand(time(0));
- cout << "time(0) = " << time(0) << endl;
- int MinIndex = 0;
- int MaxIndex = 0;
- for (int i = 0; i < size; ++i)
- {
- arr[i] = rand();
- if (arr[i] > arr[MaxIndex]) MaxIndex = i;
- if (arr[i] < arr[MinIndex]) MinIndex = i;
- }
- monitor(arr);
- cout << "Max " << MaxIndex << endl;
- cout << "minimum " << MinIndex << endl;
- return 0;
- }
- ///////////////////////////////////////////////////////
- void monitor(int *p)
- {
- for (int i = 0; i < size; ++i)
- {
- cout << p[i] << ", ";
- }
- cout << endl;
- }
- /*
- #include <stdlib.h>
- #include <time.h>
- #include <iostream>
- using namespace std;
- const int size = 20;
- int arr[size] = {10, 11, 22, 3, 44, 75, 86, 997, 8, 99,
- 0, 1, 2,13, 4, 5, 6, 97, 28, 19};
- void monitor();
- ////////////////////////////////////////////////////
- int main()
- {
- const int size = 20;
- srand(time(0));
- cout << "time(0) = " << time(0) << endl;
- int MinIndex = 0;
- int MaxIndex = 0;
- for (int i = 0; i < size; ++i)
- {
- arr[i] = rand();
- if (arr[i] > arr[MaxIndex]) MaxIndex = i;
- if (arr[i] < arr[MinIndex]) MinIndex = i;
- }
- monitor();
- cout << "Max " << MaxIndex << endl;
- cout << "minimum " << MinIndex << endl;
- return 0;
- }
- ///////////////////////////////////////////////////////
- void monitor()
- {
- for (int i = 0; i < size; ++i)
- {
- cout << arr[i] << ", ";
- }
- cout << endl;
- }
- */
- /*
- #include <iostream>
- using namespace std;
- ////////////////////////////////////////////////////
- int main()
- {
- const int size = 20;
- int arr[size] = {10, 11, 22, 3, 44, 75, 86, 997, 8, 99,
- 0, 1, 2,13, 4, 5, 6, 97, 28, 19};
- int MinIndex = 0;
- int MaxIndex = 0;
- for (int i = 0; i < size; ++i)
- {
- if (arr[i] > arr[MaxIndex]) MaxIndex = i;
- if (arr[i] < arr[MinIndex]) MinIndex = i;
- }
- cout << "Max " << MaxIndex << endl;
- cout << "minimum " << MinIndex << endl;
- return 0;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement