-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1094.c
More file actions
48 lines (36 loc) · 728 Bytes
/
1094.c
File metadata and controls
48 lines (36 loc) · 728 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
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
int main() {
int N, quant, i=0, total=0, R=0, C=0, S=0;
char tipo;
float pc, pr, ps, c, r, s;
scanf("%i", &N);
while(i<N){
scanf("%i", &quant);
scanf(" %c", &tipo);
total+= quant;
if(tipo=='R'){
R+= quant;
}
if(tipo=='S'){
S+= quant;
}
else if(tipo=='C'){
C+= quant;
}
i++;
}
c= C;
r= R;
s= S;
pc= (c/total)*100;
pr= (r/total)*100;
ps= (s/total)*100;
printf("Total: %i cobaias\n", total);
printf("Total de coelhos: %i\n", C);
printf("Total de ratos: %i\n", R);
printf("Total de sapos: %i\n", S);
printf("Percentual de coelhos: %.2f %\n", pc);
printf("Percentual de ratos: %.2f %\n", pr);
printf("Percentual de sapos: %.2f %\n", ps);
return 0;
}