2009-01-10 20:50:12來源不明

ACM 382 Perfection

簡單的求因數問題!

/***********************************************************/

  1. #include<stdio.h>         
  2. #include<stdlib.h>      
  3. #include<string.h>      
  4. main()      
  5. {      
  6.  int a,temp,x,y;      
  7.  printf("PERFECTION OUTPUT\n");      
  8.  while(scanf("%d",&x)==1&&x!=0)           
  9.   {    temp=0;      
  10.    for(a=1;a<x;a++)      
  11.     {      
  12.       if(x%a==0)      
  13.        temp=temp+a;      
  14.     }      
  15.    if(temp==x) printf("%5d  PERFECT\n",x);      
  16.    if(temp<x) printf("%5d  DEFICIENT\n",x);      
  17.    if(temp>x) printf("%5d  ABUNDANT\n",x);      
  18.   }      
  19.   printf("END OF OUTPUT\n");         
  20.  return 0;           
  21. }