Creative Commons License Foxbond's Repo

/** (c) 2012 Michał (Foxbond) Chraniuk */
#include <cstdlib>
#include <iostream>
#include <time.h>
#include <cstdlib>

using namespace std;


int los (){
   return rand()%50+1; 
    
}

int main(int argc, char *argv[])
{
    int ile=0;
    int tab[6];
    bool odnowa = false;
    srand(time(NULL));
    cout << "Podaj ile:";
    cin >> ile;
    
    for (int i=0;i<ile;i++){
        
       for (int ii=0;ii<6;ii++){
           tab[ii] = los();
       }
       
       do {
           odnowa=false;
           for (int ii=0;ii<6;ii++){
               for (int iii=0;iii<6;iii++){
                   if (ii == iii) { break; }
                   if (tab[ii] == tab[iii]){
                        tab[ii] = los();
                             odnowa = true; 
                    }
               }
            } 
       }while(odnowa);
        
        for (int ii=0;ii<6;ii++){
           if (tab[ii] < 10){
              cout << " " << tab[ii] << " ";        
           }else{
              cout << tab[ii] << " ";
           }
       }
       
       cout << "\n";
    }
    
    
    system("PAUSE");
    return EXIT_SUCCESS;
}

> Back