-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_1094(3).c
executable file
·63 lines (52 loc) · 1.2 KB
/
_1094(3).c
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//#1094 by Neilor Tonin.
#include <stdio.h>
//Function portotype
void guineaData(int, int, int);
int main ()
{
//Receiving total of inputs.
int N;
scanf ("%i", &N);
//Receiving data about each animal.
int i;
int temp;
int tC = 0, tR = 0, tS = 0;
char A;
for (i =0; i < N; i ++)
{
scanf ("%i %c", &temp, &A);
if (A == 'C')
{
tC += temp;
}
else if (A == 'R')
{
tR += temp;
}
else
{
tS += temp;
}
}
guineaData(tC, tR, tS);
return 0;
}
void guineaData(int tC, int tR, int tS)
{
//Calculating.
int total;
total = tC + tR + tS;
float perceC, perceR, perceS;
perceC = (float) 100/total * tC;
perceR = (float) 100/total * tR;
perceS = (float) 100/total * tS;
//Just showing the output.
printf ("Total: %i cobaias\n", total);
printf ("Total de coelhos: %i\n", tC);
printf ("Total de ratos: %i\n", tR);
printf ("Total de sapos: %i\n", tS);
printf ("Percentual de coelhos: %.2f %%\n", perceC);
printf ("Percentual de ratos: %.2f %%\n", perceR);
printf ("Percentual de sapos: %.2f %%\n", perceS);
}
//Ok