-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1094.cpp
More file actions
38 lines (28 loc) · 1.01 KB
/
1094.cpp
File metadata and controls
38 lines (28 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int x, coelhos=0, ratos=0, sapos=0, total=0, quantia=0;
string cobaia;
double pCoelhos, pRatos, pSapos;
cin >> x;
for(int i=0; i<x; i++) {
cin >> quantia >> cobaia;
if(cobaia == "C") coelhos += quantia;
else if(cobaia == "R") ratos += quantia;
else if(cobaia == "S") sapos += quantia;
}
total = coelhos + ratos + sapos;
pCoelhos = (100.00 * coelhos) / total;
pRatos = (100.00 * ratos) / total;
pSapos = (100.00 * sapos) / total;
cout << fixed << setprecision(2);
cout << "Total: " << total << " cobaias" << endl;
cout << "Total de coelhos: " << coelhos << endl;
cout << "Total de ratos: " << ratos << endl;
cout << "Total de sapos: " << sapos << endl;
cout << "Percentual de coelhos: " << pCoelhos << " %" << endl;
cout << "Percentual de ratos: " << pRatos << " %" << endl;
cout << "Percentual de sapos: " << pSapos << " %" << endl;
return 0;
}