diff --git a/AcWing/718/718.cpp b/AcWing/718/718.cpp new file mode 100644 index 00000000..5b5ccb73 --- /dev/null +++ b/AcWing/718/718.cpp @@ -0,0 +1,31 @@ +#include + +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; +}