Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include <cmath>
  4. #include <iomanip>
  5.  
  6.  
  7. using namespace std;
  8.  
  9.  
  10.  
  11. int main()
  12. {
  13. int n;
  14. cin >> n;
  15.  
  16. int p1, p2, p3;
  17. double ans1, ans2, ans3;
  18. for (int i = 1; i <= n; i++)
  19. {
  20. int number;
  21. cin >> number;
  22.  
  23. if (number % 2 == 0)
  24. {
  25. p1 = p1 + 1;
  26. }
  27. else if (number % 3 == 0)
  28. {
  29. p2 = p2 + 1;
  30. }
  31. else if (number % 4 == 0)
  32. {
  33. p3 = p3 + 1;
  34. }
  35. }
  36. ans1 = n / p1 * 100;
  37. ans2 = n / p2 * 100;
  38. ans3 = n / p3 * 100;
  39.  
  40. cout << fixed << setprecision(2) << ans1 << '%' << endl;
  41. cout << fixed << setprecision(2) << ans2 << '%' << endl;
  42. cout << fixed << setprecision(2) << ans3 << '%' << endl;
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement