-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBC1094.cpp
More file actions
35 lines (33 loc) · 956 Bytes
/
BC1094.cpp
File metadata and controls
35 lines (33 loc) · 956 Bytes
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
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int rabbit, rat, frog, n;
rabbit = rat = frog = 0;
cin >> n;
for (int i = 0; i < n; i++)
{
int amount;
char type;
cin >> amount >> type;
if (type == 'C')
rabbit += amount;
else if (type == 'R')
rat += amount;
else
frog += amount;
}
int total = rabbit + rat + frog;
cout << "Total: " << total << " cobaias" << endl;
cout << "Total de coelhos: " << rabbit << endl;
cout << "Total de ratos: " << rat << endl;
cout << "Total de sapos: " << frog << endl;
float temp = (float)(rabbit * 100) / total;
printf("Percentual de coelhos: %.2f %%\n", temp);
temp = (float)(rat * 100) / total;
printf("Percentual de ratos: %.2f %%\n", temp);
temp = (float)(frog * 100) / total;
printf("Percentual de sapos: %.2f %%\n", temp);
return 0;
}