fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <time.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int i=0,
  10. pow=0,
  11. j=50;
  12.  
  13. bool distinct = true;
  14. srand(time(NULL));
  15.  
  16. int los[50] = {0};
  17.  
  18. while (i<50)
  19. {
  20.  
  21. pow = rand()%10+1;
  22. j=50;
  23. distinct = true;
  24.  
  25. while(j>=0) //sprawdza kiczby aż do pierwszej w tablicy
  26. {
  27. if (pow==los[j])
  28. {
  29. los[i] = 0;
  30. distinct = false;
  31. }
  32. j--;
  33. //cout<<j;
  34. }
  35.  
  36. if(distinct)
  37. los[i]=pow;
  38.  
  39. cout.width(5);
  40. cout<<los[i];
  41. i++;
  42. }
  43.  
  44.  
  45. return 0;
  46.  
  47. }
  48.  
  49.  
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
   10    0    2    4    7    6    0    0    0    5    3    0    9    0    0    0    0    0    8    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0