Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main() {
- int tab[6];
- int lotto_tab[6];
- int liczba;
- int lotto;
- int trafione=0;
- unsigned long int ile_razy =0;
- srand (time(NULL));
- for (int j=0;j<6;j++){ // wyzerowanie tablic
- tab[j]=0;
- lotto_tab[j]=0;
- }
- for(int i=0;i<6;i++){ // wprowadzenie twoich liczb
- cin >> liczba;
- if (liczba>0 && liczba < 50){
- tab[i]=liczba;
- for(int k=0; k<i; k++){
- if(tab[k]==liczba){
- cout<<"niewlasciwa liczba"<<endl;
- i--;
- }
- }
- }
- }
- do
- {
- cout << "proba nr : " << ile_razy << endl;
- for(int l=0;l<6;l++){ // lowowanie liczb
- lotto = (rand() % 49 ) + 1;
- lotto_tab[l]=lotto;
- for(int m=0;m<l;m++){
- if(lotto_tab[m]==lotto)
- l--;
- }
- }
- for(int x=0;x<6;x++) // trafione liczby
- for(int y=0;y<6;y++){
- if(tab[x]==lotto_tab[y])
- trafione++;
- }
- ile_razy++;
- }
- while(trafione!=6);
- cout << ile_razy;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement