প্রবলেমটি পড়ুন এবং বুঝুন
#include<iostream>
using namespace std;
int which_number(int a)
{
long int sum=0,d;
for(int i=1; i*i<=a; i++)
{
if(a%i==0)
{
d=a/i;
if(i==a)
continue;
else if(i==1)
sum+=1;
else
sum=sum+i+d;
}
}
if(sum==a)
cout<<a<<" PERFECT\n";
else if(sum<a)
cout<<a<<" DEFICIENT\n";
else
cout<<a<<" ABUNDANT\n";
}
int main()
{
int a,i=0;
while((cin>>a))
{
if(i==0)
{
cout<<"PERFECTION OUTPUT\n";
i++;
}
if(a==0) break;
if(a<10) cout<<" ";
else if(a<100) cout<<" ";
else if(a<1000) cout<<" ";
else if(a<10000) cout<<" ";
which_number(a);
}
cout<<"END OF OUTPUT\n";
return 0;
}
#include<iostream>
using namespace std;
int which_number(int a)
{
long int sum=0,d;
for(int i=1; i*i<=a; i++)
{
if(a%i==0)
{
d=a/i;
if(i==a)
continue;
else if(i==1)
sum+=1;
else
sum=sum+i+d;
}
}
if(sum==a)
cout<<a<<" PERFECT\n";
else if(sum<a)
cout<<a<<" DEFICIENT\n";
else
cout<<a<<" ABUNDANT\n";
}
int main()
{
int a,i=0;
while((cin>>a))
{
if(i==0)
{
cout<<"PERFECTION OUTPUT\n";
i++;
}
if(a==0) break;
if(a<10) cout<<" ";
else if(a<100) cout<<" ";
else if(a<1000) cout<<" ";
else if(a<10000) cout<<" ";
which_number(a);
}
cout<<"END OF OUTPUT\n";
return 0;
}
No comments:
Post a Comment