Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- const int ROZMIAR{ 6 };
- bool czyJuzJest(int liczba, int tablica[], int n) {
- for (auto i{ 0 }; i < n; ++i) {
- if (tablica[i] == liczba) {
- return true;
- }
- }
- return false;
- }
- void wypelni(int tab[]) {
- for (int i = 0; i < ROZMIAR; ++i) {
- int losowa;
- do {
- losowa = rand() % 49 + 1;
- } while (czyJuzJest(losowa, tab, i));
- tab[i] = losowa;
- }
- }
- void wyswietl(int tab[]) {
- for (int i = 0; i < ROZMIAR; ++i) {
- cout << tab[i] << ' ';
- }
- cout << endl;
- }
- int main() {
- int tab[ROZMIAR];
- srand(time(nullptr));
- wypelni(tab);
- wyswietl(tab);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement