其他分享
首页 > 其他分享> > poj 1528(水题)

poj 1528(水题)

作者:互联网

#include<iostream>
#include<cstdio>
/*
PERFECTION OUTPUT
   15  DEFICIENT
   28  PERFECT
    6  PERFECT
   56  ABUNDANT
60000  ABUNDANT
   22  DEFICIENT
  496  PERFECT
END OF OUTPUT
*/ 
using namespace std;
int main(){
    int i,j,k,a[105],s[105],f[105];
    i = 0;
    while(scanf("%d",&a[i])==1&&a[i]){
        for(s[i]=0,j=1;j<=a[i]/2;j++){
            if(a[i]%j==0){
                s[i] += j;
            }
        }
        if(s[i]==a[i]){
            f[i] = 0;
        }
        else if(s[i]>a[i]){
            f[i] = 1;
        }
        else if(s[i]<a[i]){
            f[i] = -1;
        }
        i++;
    }
    printf("PERFECTION OUTPUT\n");
    for(j=0;j<i;j++){
        printf("%5d  ",a[j]);
        if(f[j]==0){
            printf("PERFECT");
        }
        else if(f[j]==1){
            printf("ABUNDANT");
        }
        else if(f[j]==-1){
            printf("DEFICIENT");
        }
        printf("\n");
    }
    printf("END OF OUTPUT\n");
    return 0;
}

 

标签:PERFECT,include,水题,int,DEFICIENT,poj,ABUNDANT,1528,105
来源: https://www.cnblogs.com/stevenzrx/p/15076780.html