Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //50-elementowa tablice wypelnic liczbami lopsowymi z przedzialu podanego przez urzytkownika
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- using namespace std;
- int tab[50];
- int gen;
- int i;
- int lmin;
- int lmax;
- int temp;
- int lmod;
- main()
- {
- cout << "podaj najnizsza liczbe przedzialu: ";
- cin >> lmin;
- cout << "podaj najwieksza liczbe przedzialu: ";
- cin >> lmax;
- if(lmin>lmax)
- {
- temp = lmin;
- lmin = lmax;
- lmax = temp;
- }
- lmod = (lmax-(lmin-1)) + lmin;
- //do debugowania
- cout << lmod << endl;
- srand(time(NULL));
- for(i=0;i<50;i++)
- {
- tab[i] = rand()%lmod;
- }
- for(i=0;i<50;i++)
- {
- cout << i+1 << " liczba to: " << tab[i] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement