Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9.  
  10. int main() {
  11.     int tab[6];
  12.     int lotto_tab[6];
  13.     int liczba;
  14.     int lotto;
  15.     int trafione=0;
  16.     unsigned long int ile_razy =0;
  17.    
  18.     srand (time(NULL));
  19.    
  20.     for (int j=0;j<6;j++){ // wyzerowanie tablic
  21.         tab[j]=0;
  22.         lotto_tab[j]=0;
  23.     }
  24.    
  25.     for(int i=0;i<6;i++){   // wprowadzenie twoich liczb
  26.         cin >> liczba;
  27.         if (liczba>0 && liczba < 50){
  28.         tab[i]=liczba;
  29.         for(int k=0; k<i; k++){
  30.             if(tab[k]==liczba){
  31.                 cout<<"niewlasciwa liczba"<<endl;
  32.                 i--;
  33.             }
  34.         }
  35.     }
  36.     }
  37.    
  38.     do
  39.     {
  40.     cout << "proba nr : " << ile_razy << endl;
  41.     for(int l=0;l<6;l++){   // lowowanie liczb
  42.         lotto = (rand() % 49 ) + 1;
  43.             lotto_tab[l]=lotto;
  44.             for(int m=0;m<l;m++){
  45.                 if(lotto_tab[m]==lotto)
  46.                 l--;   
  47.             }
  48. }
  49.    
  50.        
  51.     for(int x=0;x<6;x++)    // trafione liczby
  52.         for(int y=0;y<6;y++){
  53.             if(tab[x]==lotto_tab[y])
  54.             trafione++;
  55.     }
  56. ile_razy++;
  57. }
  58. while(trafione!=6);
  59.    
  60. cout << ile_razy;
  61.    
  62.        
  63.        
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement