Răspuns :
Răspuns:
1.
#include <iostream>
using namespace std;
int main()
{
int x;
cin>>x;
cout<<x*x+2*x+1;
return 0;
}
2.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<sqrt(a*a+b*b);
return 0;
}
3.
#include <iostream>
using namespace std;
int main()
{
int x;
cin>>x;
if(x%2==0)
cout<<"par";
else
cout<<"impar";
return 0;
}
4.
#include <iostream>
using namespace std;
int main()
{
int x;
cin>>x;
if(x<=3)
cout<<x*x-4;
else
cout<<x+1;
return 0;
}
5.
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a>b)
cout<<a+b;
else if(a<b)
cout<<a*b;
else
cout<<"Egalitate";
return 0;
}
6.
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a%2==0 &&b%2==0){
int c;
cin>>c;
cout<<(a+b+c)/3;
}
else{
cout<<a*a+b*b;
}
return 0;
}
7.
#include <iostream>
using namespace std;
int main()
{
int a;
int cifImpare=0;
cin>>a;
while(a){
if(a%2==1){
cifImpare++;
}
a/=10;
}
cout<<cifImpare;
return 0;
}
8.
#include <iostream>
using namespace std;
int main()
{
int x;
cin>>x;
int oglindit=0;
while(x){
oglindit=oglindit*10+x%10;
x/=10;
}
cout<<oglindit;
return 0;
}
9.
#include <iostream>
using namespace std;
int main()
{
int x;
cin>>x;
int s=0;
int intalnite=0;
while(x){
if(x>=0){
s+=x;
intalnite++;
}
cin>>x;
}
cout<<s/intalnite;
return 0;
}
10.
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
cout<<n*(n+1)*(2*n+1)/6;
return 0;
}
Explicație: