Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- using namespace std;
- int tab[200];
- int ilosc[20];
- int i;
- int a;
- int l;
- main()
- {
- srand(time(NULL));
- for(i=0; i<200; i++)
- {
- tab[i] = rand()%21 - 10;
- cout << tab[i] << "." << endl;
- a = -10;
- while(a <= 10)
- {
- if(tab[i] == a)
- {
- ilosc[a+10] = ilosc[a+10] + 1;
- break;
- }
- else
- {
- a++;
- }
- }
- }
- l = -10;
- for (i=0; i<20; i++)
- {
- cout << "liczba " << l << " wystapila " << ilosc[i] << " razy" << endl;
- l++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement