-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_1164(2).c
executable file
·69 lines (60 loc) · 1.02 KB
/
_1164(2).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
64
65
66
67
68
69
//#1164 Perfect Number by Neilor Tonin
#include <stdio.h>
int sum_dividers(int);
int main ()
{
//Receiving the amount of tests case;
int total;
scanf ("%i", &total);
//Receiving each test case and verifying.
int i;
int temp;
int out[total];
for (i = 0; i < total; i++)
{
scanf ("%i", &temp);
if (sum_dividers(temp) == 1)
{
out[i] = temp;
}
else
{
out[i] = temp * (-1);
}
}
//Shwing each output.
for (i = 0; i < total; i++)
{
if (out[i] > 0)
{
printf ("%i eh perfeito\n", out[i]);
}
else
{
printf ("%i nao eh perfeito\n", (out[i]*-1));
}
}
return 0;
}
int sum_dividers(int x)
{
int i;
int res;
res = 0;
for (i = 1; i < x; i++)
{
if (x % i == 0)
{
res = res + i;
}
}
if (res == x)
{
return 1;
}
else
{
return 0;
}
}
//Ok