0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 12:58:48 +00:00
Baoshuo Ren 2021-08-03 16:26:31 +08:00 committed by Baoshuo Ren
parent 4d9199d715
commit c7791f11e2
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

31
AcWing/718/718.cpp Normal file
View File

@ -0,0 +1,31 @@
#include <bits/stdc++.h>
using namespace std;
int f[100], sum;
int main() {
int n;
cin >> n;
while (n--) {
int a;
char t;
cin >> a >> t;
if (t == 'C') {
f[1] += a;
} else if (t == 'R') {
f[2] += a;
} else {
f[3] += a;
}
sum += a;
}
cout << "Total: " << sum << " animals" << endl
<< "Total coneys: " << f[1] << endl
<< "Total rats: " << f[2] << endl
<< "Total frogs: " << f[3] << endl
<< "Percentage of coneys: " << fixed << setprecision(2) << 100.0 * f[1] / sum << " %" << endl
<< "Percentage of rats: " << fixed << setprecision(2) << 100.0 * f[2] / sum << " %" << endl
<< "Percentage of frogs: " << fixed << setprecision(2) << 100.00 * f[3] / sum << " %" << endl;
return 0;
}