Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <windows.h>
- using namespace std;
- int losuj(int ilosc,int poczatek, int koniec)
- {
- int *tab;
- tab = new int[ilosc];
- bool check;
- int liczba;
- srand(time(NULL));
- for (int i=1; i<=ilosc; i++)
- {
- do
- {
- liczba = rand()% (poczatek-koniec)+poczatek;
- check=true;
- for (int j=0;j<i;j++)
- if (liczba == tab[j] )
- {
- check=false;
- }
- } while (!check);
- tab[i]=liczba;
- cout<<tab[i]<<endl;
- }
- return tab[i];
- }
- int main()
- {
- int ilosc;
- int poczatek;
- int koniec;
- int *tab;
- tab = new int[ilosc];
- cout << "Czesc, podaj ile liczb wyloscowac:"<< endl;
- cin>>ilosc;
- cout<< "Podaj poczatek przedzialu: "<<endl;
- cin>>poczatek;
- cout<< "Podaj koniec przedzialu: "<<endl;
- cin>>koniec;
- cout<<endl;
- tab[i]=losuj(int ilosc, poczatek, int koniec);
- delete [] tab;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement