Hi Vadiu:
Here are few modification that I made to your code and it got Ac.
--> First of all , you don't have to use strtok cos you know it terminates with a zero.
--> 1 is not a perfect number
--> You don't have to store the numbers in an array before processing..
.. the best is to read a number and process it immediately.
Here is a slight modification of your code which got AC. Note the changes
[c]
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
int check(int bah);
int a;
int main( )
{
printf("PERFECTION OUTPUT\n");
while( scanf("%d", &a ) )
{
if( a == 0 )
break;
switch( check(a) )
{
case 0: printf("%5d %s\n", a, "DEFICIENT");break;
case 1: printf("%5d %s\n", a, "PERFECT");break;
case 2: printf("%5d %s\n", a, "ABUNDANT");break;
}
}
printf("END OF OUTPUT\n");
return 0;
}
int check(int bah)
{
int soma=0, j;
if(bah==1)
return 0;
for(j=1; j<bah; j++)
{
if(bah%j==0)
soma+=j;
}
if(soma>bah)
return 2;
if (soma==bah)
return 1;
else return 0;
}
[/c]
Hope it helps and that you can see the difference.
![:)](./images/smilies/icon_smile.gif)