Guest User

Untitled

a guest
May 17th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <conio.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int arr[] = { 20, 40, 30, 50, 22, 16, 15, 88, 21, 14, 17, 44, 25, 55, 66, 77, 89, 63, 11 };
  10. int(*pArr)[sizeof(arr) / sizeof(*arr)] = &arr;
  11. unsigned minIndex = 0;
  12. unsigned maxIndex = 0;
  13. for (unsigned i = 1; i < sizeof(*pArr) / sizeof(**pArr); ++i) {
  14. if (pArr[0][i] < pArr[0][minIndex]) {
  15. minIndex = i;
  16. continue;
  17. }
  18. if (pArr[0][i] > pArr[0][maxIndex]) {
  19. maxIndex = i;
  20. continue;
  21. }
  22. }
  23. cout << "minimum: " << (*pArr)[minIndex] << endl;
  24. cout << "maximum: " << (*pArr)[maxIndex] << endl;
  25. _getch();
  26. }
Add Comment
Please, Sign In to add comment