Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- int p1, p2, p3;
- double ans1, ans2, ans3;
- for (int i = 1; i <= n; i++)
- {
- int number;
- cin >> number;
- if (number % 2 == 0)
- {
- p1 = p1 + 1;
- }
- else if (number % 3 == 0)
- {
- p2 = p2 + 1;
- }
- else if (number % 4 == 0)
- {
- p3 = p3 + 1;
- }
- }
- ans1 = n / p1 * 100;
- ans2 = n / p2 * 100;
- ans3 = n / p3 * 100;
- cout << fixed << setprecision(2) << ans1 << '%' << endl;
- cout << fixed << setprecision(2) << ans2 << '%' << endl;
- cout << fixed << setprecision(2) << ans3 << '%' << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement