Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main() {
  7. int liczba;
  8. int max;
  9. int min;
  10. int poz_min = 0;
  11. int poz_max = 0;
  12. int obecna_pozycja = 0;
  13.  
  14. while (cin >> liczba)
  15. {
  16. if (liczba >= max || obecna_pozycja == 0) {
  17. max = liczba;
  18. poz_max = obecna_pozycja;
  19. }
  20.  
  21. if (liczba < min || obecna_pozycja == 0) {
  22. min = liczba;
  23. poz_min = obecna_pozycja;
  24. }
  25.  
  26. obecna_pozycja++;
  27. }
  28.  
  29. cout << min << endl;
  30. cout << poz_min << endl;
  31. cout << max << endl;
  32. cout << poz_max << endl;
  33.  
  34.  
  35. system("pause");
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement