-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1094.cpp
41 lines (33 loc) · 945 Bytes
/
1094.cpp
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
39
40
41
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n;
double q, coelho = 0, rato = 0, sapo = 0;
char t;
cin >> n;
for (int i = 0; i < n; ++i)
{
cin >> q >> t;
if(t == 'C'){
coelho += q;
}else if(t == 'R'){
rato += q;
}else{
sapo += q;
}
}
double total = (coelho + rato + sapo);
double c = ((100 * coelho) / total);
double r = ((100 * rato) / total);
double s = ((100 * sapo) / total);
cout << "Total: " << total << " cobaias" << endl;
cout << "Total de coelhos: " << coelho << endl;
cout << "Total de ratos: " << rato << endl;
cout << "Total de sapos: " << sapo << endl;
cout << "Percentual de coelhos: " << fixed << setprecision(2) << c << " %" << endl;
cout << "Percentual de ratos: " << fixed << setprecision(2) << r << " %" << endl;
cout << "Percentual de sapos: " << fixed << setprecision(2) << s << " %" << endl;
return 0;
}