GabrielRuta

zad9

Apr 16th, 2020
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5. int a=1;
  6. int b=50;
  7. int c=51;
  8. int d;
  9. int main()
  10. {
  11. int tab[10];
  12. for(int i=0;i<10;i++)
  13. {
  14. tab[i]=a+rand()%(b-a+1);
  15. if(tab[i]<c)
  16. {
  17. c=tab[i];
  18. d=i;
  19. }
  20. if(tab[i]>a)
  21. {
  22. a=tab[i];
  23. b=i;
  24. }
  25. }
  26. cout << "najmniejszy: tab["<<d<<"] wynosi: " << tab[d] << endl;
  27. cout << "najwiekszy: tab["<<b<<"] wynosi: " << tab[b]<<endl;
  28. return 0;
  29. }
Add Comment
Please, Sign In to add comment