Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <conio.h>
- using namespace std;
- int main()
- {
- int arr[] = { 20, 40, 30, 50, 22, 16, 15, 88, 21, 14, 17, 44, 25, 55, 66, 77, 89, 63, 11 };
- int(*pArr)[sizeof(arr) / sizeof(*arr)] = &arr;
- unsigned minIndex = 0;
- unsigned maxIndex = 0;
- for (unsigned i = 1; i < sizeof(*pArr) / sizeof(**pArr); ++i) {
- if (pArr[0][i] < pArr[0][minIndex]) {
- minIndex = i;
- continue;
- }
- if (pArr[0][i] > pArr[0][maxIndex]) {
- maxIndex = i;
- continue;
- }
- }
- cout << "minimum: " << (*pArr)[minIndex] << endl;
- cout << "maximum: " << (*pArr)[maxIndex] << endl;
- _getch();
- }
Add Comment
Please, Sign In to add comment