Threed90

Хистограма/Histogram

Dec 20th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int n = 0;
  7.  
  8.     scanf_s("%d", &n);
  9.  
  10.     float count2 = 0;
  11.     float count3 = 0;
  12.     float count4 = 0;
  13.  
  14.     for (int i = 0; i < n; i++)
  15.     {
  16.         int num;
  17.         scanf_s("%d", &num);
  18.  
  19.         if (num % 2 == 0)
  20.         {
  21.             count2++;
  22.         }
  23.  
  24.         if (num % 3 == 0)
  25.         {
  26.             count3++;
  27.         }
  28.  
  29.         if (num % 4 == 0)
  30.         {
  31.             count4++;
  32.         }
  33.     }
  34.  
  35.     printf_s("%.2f%%\n", ((count2 / n) * 100));
  36.     printf_s("%.2f%%\n", ((count3 / n) * 100));
  37.     printf_s("%.2f%%\n", ((count4 / n) * 100));
  38.  
  39.     system("pause");
  40.     return 0;
  41. }
Add Comment
Please, Sign In to add comment