Advertisement
v4m4v4

DelenieBezOstatak

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