👤
a fost răspuns

stie careva?
Clasa a 10 a C++


Stie Careva Clasa A 10 A C class=

Răspuns :

Explicație:

1.

#include <iostream>

using namespace std;

int perfect(int n)

{

int s=0;

for(int i=1;i<=n/2;i++)

{

if(n%i==0)

{s+=i;}

}

if(s==n)

{return s;}

else

{return 0;}

}

int main()

{

int x,s=0;

cin>> x;

for(int i=1:i<=x;i++)

{

if(perfect(i))

{cout<<i<<endl;}

}

return 0;

}

2.

#include <iostream>

using namespace std;

int main()

{

int m,n,s1=0,s2=0,cif1,cif2;

cin>>m>>n;

int cm=m,cn=n;

while(m)

{

cif1=m%10;

s1=s1+cif1;

m=m/10

}

while(n)

{

cif2=n%10;

s2=s2+cif2;

n=n/10

}

if(s1>s2)

cout<<cm;

else

cout<<cn;

return 0;

}