Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <cstdlib>
  4. #include <ctime>
  5. #include <conio.h>
  6. using namespace std;
  7.  
  8.  
  9. int main()
  10. {
  11. srand(time(NULL));
  12. int tab[10];
  13. int x=0;
  14. int a,b=0;
  15. int j;
  16. cout<<"Poczatek"<<endl;
  17. cin>>a;
  18.  
  19. cout<<"koniec"<<endl;
  20. cin>>b;
  21.  
  22.  
  23.  
  24.  
  25. for (int i=0; i<9; i++)
  26. {
  27. int f=0;
  28.  
  29. do
  30. {
  31. x=a+int((b-a+1)*rand()/(RAND_MAX+1.0));
  32.  
  33. for (j=0; j<9; j++);
  34. {
  35.  
  36. if(tab[j]==x)
  37. {
  38. f=1;
  39. }
  40. if (tab[j]!=x)
  41. {
  42. f=0;
  43. }
  44.  
  45. }
  46.  
  47.  
  48.  
  49. } while(f==1);
  50.  
  51. tab[i]=x;
  52. cout<<tab[i]<<" ";
  53.  
  54.  
  55.  
  56. }
  57.  
  58.  
  59.  
  60.  
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement