Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- int N=3000;
- int MyMas[N];
- srand(time(NULL));
- for (int i = 0; i < N; i++ )
- {
- MyMas[i]=rand()%5+1;
- cout<<"MyMas["<<i<<"]="<<MyMas[i]<<endl;
- }
- int n1 = 0, n2 = 0, n3 = 0, n4 = 0, n5 = 0;
- for (int i = 0; i < N; i++)
- {
- if(MyMas[i] == 1) n1++;
- else if(MyMas[i] == 2) n2++;
- else if(MyMas[i] == 3) n3++;
- else if(MyMas[i] == 4) n4++;
- else if(MyMas[i] == 5) n5++;
- }
- cout<<"chyslo 1 -\t"<< (double)n1 * 100. / N <<" %"<<endl;
- cout<<"chyslo 2 -\t"<< (double)n2 * 100. / N <<" %"<<endl;
- cout<<"chyslo 3 -\t"<< (double)n3 * 100. / N <<" %"<<endl;
- cout<<"chyslo 4 -\t"<< (double)n4 * 100. / N <<" %"<<endl;
- cout<<"chyslo 5 -\t"<< (double)n5 * 100. / N <<" %"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement