Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- srand (time ( NULL));
- int n = 0;
- while (n < 1)
- {
- cout << "Podaj rozmiar tablicy: ";
- cin >> n;
- }
- int* T = new int[n];
- int losowa;
- for(int i = 0; i < n; i++)
- {
- losowa = (rand() %31) + 0;
- T[i] = losowa;
- cout << T[i] << " ";
- }
- int P[31];
- for(int i = 0; i < 32; i++)
- {
- P[i] = 0;
- }
- for(int i = 0; i < n; i++)
- {
- P[ T[i] ] ++;
- }
- int x = 0;
- for(int i = 0; i != 31; i++)
- {
- for (int j = 0; j != P[i]; j++)
- {
- T[x] = i;
- x++;
- }
- }
- cout<<endl;
- for(int f = 0; f < n; f++){
- cout << T[f] << " ";
- }
- delete[] T;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement