Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Napisz program, który tworzy 6-elementową tablicę liczb naturalnych, wypełnia ją liczbami losowymi z przedziału od 1 do 49,
- a następnie wypisuje te liczby na ekran*/
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- const short N = 6;
- void wypelnij_tablice(short* tab)
- {
- for(short i = 0; i < N; ++i)
- tab[i] = 1 + rand() % 49;
- }
- void wypisz_tablice(short* tab)
- {
- for(short i = 0; i < N; ++i)
- cout << tab[i] << '\t';
- cout << endl;
- }
- int main()
- {
- short tablica[N];
- srand(time(nullptr));
- wypelnij_tablice(tablica);
- wypisz_tablice(tablica);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement