Problems
Problems
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a>b && a>c)
cout<<a;
if(b>a && b>c)
cout<<b;
if(c>a && c>b)
cout<<c;
return 0;
}
2.
#include <iostream>
using namespace std;
int main()
{
int x,y,z;
cin>>x>>y>>z;
if(x==y && x==z && y==z)
cout<<"DA";
else
cout<<"NU";
return 0;
}
3.
#include <iostream>
using namespace std;
int main()
{
int x,y,z;
cin>>x>>y>>z;
if(x!=y && x!=z && y!=z)
cout<<"DA";
else
cout<<"NU";
return 0;
}
4.
#include <iostream>
using namespace std;
int main()
{
int a,b,c,minx=0,maxx=0;
cin>>a>>b>>c;
if(a>b && a>c)
maxx=a;
if(b>a && b>c)
maxx=b;
if(c>a && c>b)
maxx=c;
if(a<b && a<c)
minx=a;
if(b<a && b<c)
minx=b;
if(c<a && c<b)
minx=c;
cout<<maxx-minx;
return 0;
}
5.
#include <iostream>
using namespace std;
int main()
{
int x,x1,x2,x3,maxx=0,midd=0,minn=0,a;
cin>>x;
x1=x/100;
x2=x/10%10;
x3=x%10;
if(x1>x2 && x1>x2)
maxx=x1;
if(x2>x1 && x2>x3)
maxx=x2;
if(x3>x2 && x3>x1)
maxx=x3;
if(x1<x2 && x1<x2)
minn=x1;
if(x2<x1 && x2<x3)
minn=x2;
if(x3<x2 && x3<x1)
minn=x3;
if(x1<maxx && x1>minn)
midd=x1;
if(x2<maxx && x2>minn)
midd=x2;
if(x3<maxx && x3>minn)
midd=x3;
a=maxx*100+midd*10+minn;
cout<<a;
return 0;
}
6.
#include <iostream>
using namespace std;
int main()
{
int x,x1,x2,x3,maxx=0,midd=0,minn=0,a;
cin>>x;
x1=x/100;
x2=x/10%10;
x3=x%10;
if(x1>x2 && x1>x2)
maxx=x1;
if(x2>x1 && x2>x3)
maxx=x2;
if(x3>x2 && x3>x1)
maxx=x3;
if(x1<x2 && x1<x2)
minn=x1;
if(x2<x1 && x2<x3)
minn=x2;
if(x3<x2 && x3<x1)
minn=x3;
if(x1<maxx && x1>minn)
midd=x1;
if(x2<maxx && x2>minn)
midd=x2;
if(x3<maxx && x3>minn)
midd=x3;
a=minn*100+midd*10+maxx;
cout<<a;
return 0;
}
7.
#include <iostream>
using namespace std;
int main()
{
int x,y,s1=0,s2=0;
cin>>x>>y;
s1=x%10+x/10%10+x/100%10+x/1000;
s2=y%10+y/10%10+y/100%10+y/1000;
if(s1>s2)
cout<<x;
else
cout<<y;
return 0;
}
8.
#include <iostream>
using namespace std;
int main()
{
float a,b,c,d,c1=0,c2=0;
cin>>a>>b>>c>>d;
c1=a/b;
c2=c/d;
if(c1>c2)
cout<<a<<"/"<<b;
else
cout<<c<<"/"<<d;
return 0;
}
9.
#include <iostream>
using namespace std;
int main()
{
int x,y,z;
cin>>x>>y>>z;
if(x*x==y*y+z*z)
cout<<"DA";
if(y*y==x*x+z*z)
cout<<"DA";
if(z*z==x*x+y*y)
cout<<"DA";
else
cout<<"NU";
return 0;
}
10.
#include <iostream>
using namespace std;
int main()
{
int z,l,a;
cin>>z>>l>>a;
if((z>=1 && z<=31)&&(l>=1 && l<=12)&&(a>=1 && a<=2021))
cout<<"Data calendaristica poate fi reprezentanta";
else
cout<<"Data calendaristica nu poate fi reprezentanta";
return 0;
}
11.
#include <iostream>
using namespace std;
int main()
{
int x1,x2,x3,maxx=0,midd=0,minn=0;
cin>>x1>>x2>>x3;
if(x1>x2 && x1>x2)
maxx=x1;
if(x2>x1 && x2>x3)
maxx=x2;
if(x3>x2 && x3>x1)
maxx=x3;
if(x1<x2 && x1<x2)
minn=x1;
if(x2<x1 && x2<x3)
minn=x2;
if(x3<x2 && x3<x1)
minn=x3;
if(x1<maxx && x1>minn)
midd=x1;
if(x2<maxx && x2>minn)
midd=x2;
if(x3<maxx && x3>minn)
midd=x3;
cout<<minn<<" "<<midd<<" "<<maxx;
return 0;
}
12.
#include <iostream>
using namespace std;
int main()
{
int x,y,z,w;
int a=999999999;
int b=-999999999;
cin>>x>>y>>z>>w;
if((x>=b && x<=a)&&(y>=b && y<=a)&&(z>=b && z<=a)&&(w>=b && w<=a))
cout<<"Aceastea pot forma o multime";
else
cout<<"Aceastea nu pot forma o multime";
return 0;
}
13.
#include <iostream>
using namespace std;
int main()
{
int x,y,z,w;
cin>>x>>y>>z>>w;
if(x*w==z*y)
cout<<"Acestea sunt direct proportionale";
else
cout<<"Acestea nu sunt direct proportionale";
return 0;
}
14.
#include <iostream>
using namespace std;
int main()
{
int x;
cin>>x;
if(x%2==0)
cout<<"Acest numar este par";
else
cout<<"Acest numar este impar";
return 0;
}
15.
#include <iostream>
using namespace std;
int main()
{
int x,y;
cin>>x>>y;
if(x%y==0)
cout<<x<<" "<<"este multiplu al lui"<<" "<<y;
else
cout<<x<<" "<<"nu este multiplu al lui"<<" "<<y;
return 0;
}
16.
#include <iostream>
using namespace std;
int main()
{
int a,b,c,x;
cin>>x>>a>>b>>c;
if(x%a==0)
cout<<x<<" "<<"este multiplu pentru"<<" "<<a;
else
cout<<x<<" "<<"nu este multiplu pentru"<<" "<<a;
cout<<endl;
if(x%b==0)
cout<<x<<" "<<"este multiplu pentru"<<" "<<b;
else
cout<<x<<" "<<"nu este multiplu pentru"<<" "<<b;
cout<<endl;
if(x%c==0)
cout<<x<<" "<<"este multiplu pentru"<<" "<<c;
else
cout<<x<<" "<<"nu este multiplu pentru"<<" "<<c;
return 0;
}
17.
#include <iostream>
using namespace std;
int main()
{
int a,b,c,x;
cin>>x>>a>>b>>c;
if(a%x==0)
cout<<x<<" "<<"este divizor pentru"<<" "<<a;
else
cout<<x<<" "<<"nu este divizor pentru"<<" "<<a;
cout<<endl;
if(b%x==0)
cout<<x<<" "<<"este divizor pentru"<<" "<<b;
else
cout<<x<<" "<<"nu este divizor pentru"<<" "<<b;
cout<<endl;
if(c%x==0)
cout<<x<<" "<<"este divizor pentru"<<" "<<c;
else
cout<<x<<" "<<"nu este divizor pentru"<<" "<<c;
return 0;
}
18.
#include <iostream>
using namespace std;
int main()
{
int a,b,k;
cin>>a>>b>>k;
if(a>0 && b>0 && k>0 && a%k==0 && b%k==0)
{
a=a/k;
b=b/k;
cout<<a<<"/"<<b;
}
else
cout<<"NU";
return 0;
}
19.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x,n;
cin>>x;
n=pow(9,x);
n=n%10;
cout<<n;
return 0;
}
20.
#include <iostream>
using namespace std;
int main()
{
int x,y,x1,y1,x2,y2;
cin>>x>>y>>x1>>y1>>x2>>y2;
if(((x-x1)*(y2-y1))==((x2-x1)*(y-y1)))
cout<<"Punctul P apartine interiorului segmentului [A,B]";
else
cout<<"Punctul P nu apartine interiorului segmentului [A,B]";
return 0;
}
21.
#include <iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a==b && a==c && b==c)
cout<<"Triunghi echilateral";
else
if((a+b>c && a+c>b && b+c>a) && (a==b || a==c || b==c))
cout<<"Triunghi isoscel";
else
cout<<"Triunghi oarecare";
return 0;
}
22.
#include <iostream>
using namespace std;
int main()
{
int x,y;
cin>>x>>y;
if(x>=0)
{
if(y>=0)
cout<<"Cadranul I";
else
cout<<"Cadranul II";
}
else
{
if(y>=0)
cout<<"Cadranul III";
else
cout<<"Cadranul IV";
}
return 0;
}