Advertisement
DidiMilikina

Задача 04 - Деление без остатък

Oct 13th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int number;
  8.     cin >> number;
  9.  
  10.     double prozent1 = 0;
  11.     double prozent2 = 0;
  12.     double prozent3 = 0;
  13.     double count_p1 = 0;
  14.     double count_p2 = 0;
  15.     double count_p3 = 0;
  16.  
  17.     for (int i = 0; i < number; i++)
  18.     {
  19.         int current_number;
  20.         cin >> current_number;
  21.  
  22.         if (current_number % 2 == 0)
  23.         {
  24.             count_p1++;
  25.             prozent1 = count_p1 / number * 100;
  26.         }
  27.         if (current_number % 3 == 0)
  28.         {
  29.             count_p2++;
  30.             prozent2 = count_p2 / number * 100;
  31.         }
  32.         if (current_number % 4 == 0)
  33.         {
  34.             count_p3++;
  35.             prozent3 = count_p3 / number * 100;
  36.         }
  37.     }
  38.     cout << fixed << setprecision(2) << prozent1 << "%" << endl;
  39.     cout << fixed << setprecision(2) << prozent2 << "%" << endl;
  40.     cout << fixed << setprecision(2) << prozent3 << "%" << endl;
  41.  
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement