Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- int randomize(int min, int max){
- return (rand()%(max-(min-1))+min);
- }
- bool wylosowano(int x, int *wylosowane){
- for(int i=0;sizeof(wylosowane);i++){
- if (wylosowane[i] == x){
- return true;
- }
- }
- return false;
- }
- void wypisz(int *wylosowane){
- cout << "Twoje numery to: ";
- for(int i=0;i<6;i++){
- if (i==5){
- cout << wylosowane[i]<<"\n";
- } else {
- cout << wylosowane[i]<<", ";
- }
- }
- }
- void wylosuj(){
- int liczby[49] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49};
- int wylosowane[6],wylosowana,wylosowanych;
- for(;sizeof(wylosowane)<6;){
- wylosowana=liczby[randomize(1,49)-1]; // Wylosowana liczba
- if (wylosowano(wylosowana,wylosowane)){
- } else {
- wylosowane[wylosowanych] = wylosowana;
- wylosowanych++;
- }
- }
- wypisz(wylosowane);
- }
- int main(){
- srand(time(NULL));
- wylosuj();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement