Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <locale>
  5. #include <conio.h>
  6. #include <string>
  7. #include <ctime>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. setlocale(LC_ALL, "rus");
  14. SetConsoleOutputCP(1251);
  15. SetConsoleCP(1251);
  16.  
  17. int arr[10]; int mini=0; int maxi=50;
  18. int arr1[maxi]={0};
  19.  
  20. srand(time(0));
  21.  
  22. for (int a=0; a<10; a++) arr[a]= mini + rand() % maxi ; //заполняем
  23.  
  24. for (int a=0; a<10; a++) cout<<arr[a]<<" "; // выводим
  25. cout<<endl;
  26.  
  27. for (int a=0; a<10; a++) { int c= arr[a]; arr1[c]++; } // считаем
  28.  
  29. for (int a=0; a<maxi; a++)
  30. {
  31. if (arr1[a]!=0)
  32. cout<<"Элементов "<<a<<" имеем "<<arr1[a]<<"штук"<<endl;
  33. }
  34. cout<<endl;
  35. system("pause");
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement