-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path1094.cpp
48 lines (36 loc) · 1.22 KB
/
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
42
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int totCoelhos, totRatos, totSapos, cobaias;
totCoelhos = totRatos = totSapos = cobaias = 0;
while(n--){
int amount;
char animal;
int coelhos, ratos, sapos, qt;
coelhos = ratos = sapos = 0;
cin >> amount >> animal;
if(animal == 'C')
coelhos += amount;
else if(animal == 'R')
ratos += amount;
else
sapos += amount;
cobaias += coelhos + ratos + sapos;
totCoelhos += coelhos;
totRatos += ratos;
totSapos += sapos;
}
printf("Total: %d cobaias\n", cobaias);
printf("Total de coelhos: %d\n", totCoelhos);
printf("Total de ratos: %d\n", totRatos);
printf("Total de sapos: %d\n", totSapos);
printf("Percentual de coelhos: %.2lf ", (double)((double)totCoelhos/(double)cobaias * 100.00));
cout << "%" << "\n";
printf("Percentual de ratos: %.2lf ", (double)((double)totRatos/(double)cobaias * 100.00));
cout << "%" << "\n";
printf("Percentual de sapos: %.2lf ", (double)((double)totSapos/(double)cobaias * 100.00));
cout << "%" << "\n";
return 0;
}