Advertisement
a53

random

a53
Feb 6th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5. int main()
  6. {
  7. int n;
  8. srand(time(NULL)); /// Initializare random
  9. int maxim=rand() % 50 + 1; /// Generez primul numar si presupun ca e maxim
  10. cout<<maxim<<' '; /// si-l afisez
  11. for(int i=1;i<10;++i) /// Repet generarea a altor 9 numere
  12. {
  13. n=rand() % 50 + 1; /// Generez alt numar
  14. cout<<n<<' '; /// si-l afisez
  15. if(n>maxim) /// Daca e mai mare, il retin
  16. maxim=n;
  17. }
  18. cout<<"\nMaximul este "<<maxim;
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement