Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. srand(time(NULL));
  10. int tab[10]; // tworzy tablicy na 10 miejsc
  11. for( int a = 0; a < 10; a++)
  12. {
  13.  
  14. tab[a] = rand() % 29 + 1;
  15. cout << "Liczba" << a << ": " << tab[a] << endl;
  16.  
  17. }
  18. int najmniejszaLiczba = 30; // najmniejsza liczba obecnie to 30
  19. for( int a = 0; a < 10; a++)
  20. {
  21. if( tab[a] < najmniejszaLiczba)
  22. najmniejszaLiczba = tab[a]; // jesli liczba w tablicy jest mniejsza od obecnej najmniejszej to ja zamienia
  23. }
  24. cout << endl << "Najmniejsza liczba to: " << najmniejszaLiczba << endl;
  25.  
  26.  
  27.  
  28. return 0;
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement