From c7791f11e23358ddbdbe5b653a27bf26e84273a1 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Tue, 3 Aug 2021 16:26:31 +0800 Subject: [PATCH] =?UTF-8?q?718.=20=E5=AE=9E=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acwing.com/problem/content/submission/code_detail/6866206/ --- AcWing/718/718.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 AcWing/718/718.cpp 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; +}