poj1528

简单题

View Code
#include<iostream>

#include<iomanip>

#include<cmath>

#include<string>

using namespace std;

char level[3][20]={"DEFICIENT","PERFECT","ABUNDANT"};

char a[1000];

void output(int n)

{

    int i;

    int mid=n/2;

    int sum=1;

    for(i=2;i<=mid;i++)

    {

        if(n%i==0)

        {

            sum+=i;

        }

    }

    if(sum<n)

        cout<<setw(5)<<n<<"  "<<level[0]<<endl;

    else if(sum==n)

        cout<<setw(5)<<n<<"  "<<level[1]<<endl;

    else cout<<setw(5)<<n<<"  "<<level[2]<<endl;

}





int main()

{

    int i,j;

    int N;

    int cur;

    cout<<"PERFECTION OUTPUT"<<endl;

    while(cin>>cur&&cur!=0)

    {

        

        if(cur==0)

            break;

        if(cur==1)

        {

            cout<<setw(5)<<cur<<"  "<<level[0]<<endl;

        }

        else

            output(cur);

    }

    cout<<"END OF OUTPUT"<<endl;

    return 0;

}

 

你可能感兴趣的:(poj)