Fără 1, ajutor va rog
Răspunsuri la întrebare
Răspuns:
2.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a;
cin>>a;
if(a>0)
cout<<"Este pozitiv";
else if(a<0)
cout<<"Este negativ";
else
cout<<"Este nul";
}
3.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a+b>0)
{
if(a>b)
cout<<a<<" "<<b;
else
cout<<b<<" "<<a;
}
else
{
if(b>c)
cout<<b;
else
cout<<c;
}
return 0;
}
4.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,s=0;
cin>>n;
while(n)
{
if((n%10)%2==0)
s=s+n%10;
n=n/10;
}
cout<<s;
return 0;
}
5.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
cout<<a+b+c<<" "<<a*b*c;
return 0;
}
6.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<"Aria = "<<a*b<<'\n'<<"Perimetrul = "<<2*a+2*b;
return 0;
}
7.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x,y,r;
cin>>x>>y;
r=x-y;
cout<<"In curte sunt "<<r*2<<" aripi si "<<r*2+y*4<<" picioare";
return 0;
}
8.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,minn,maxx;
cin>>a>>b>>c;
minn=min(a,b);
minn=min(minn,c);
maxx=max(a,b);
maxx=max(maxx,c);
cout<<minn+maxx;
return 0;
}
9.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,nr1=0,nr2=0,p;
cin>>n;
p=n;
while(n)
{
if((n%10)%2==0)
nr1++;
else if((n%10)%2==1)
nr2++;
n=n/10;
}
cout<<p<<" are "<<nr1<<" cifre pare si "<<nr2<<" cifre impare";
return 0;
}
10.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,ogl=0,s=0;
cin>>n;
while(n)
{
ogl=ogl*10+n%10;
n=n/10;
}
while(ogl)
{
s=s+ogl%10;
ogl=ogl/10;
}
cout<<s;
return 0;
}
11.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a>b)
cout<<"Minimul este "<<b;
else
cout<<"Minimul este "<<a;
cout<<endl;
if(a>b)
cout<<"Maximul este "<<a;
else
cout<<"Maximul este "<<b;
return 0;
}
Explicație: