RECTANGL - Editorial

PROBLEM LINK:

Practice
Contest

Author: Hasan Jaddouh
Tester: Alexey Zayakin
Editorialist: Oleksandr Kulkov

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Common sense

PROBLEM:

You’re given four numbers a, b, c, d. You have to determine if you can make a rectangle of such lengthes.

QUICK EXPLANATION

Do what the problem asks you to do.

EXPLANATION:

In other words you have to check if two smallest and two largest numbers among this four are same. To do this you can sort all four numbers in whatever way you like and check that first two and last two numbers are both same. Example of solution:

int a[4];
cin >> a[0] >> a[1] >> a[2] >> a[3];
sort(a, a + 4);
cout << (a[0] == a[1] && a[2] == a[3] ? "YES" : "NO") << "\n";

AUTHOR’S AND TESTER’S SOLUTIONS:

Author’s solution can be found here.
Tester’s solution can be found here.

RELATED PROBLEMS:

#include<stdio.h>

void main()
{
int a,b,c,d,e;
clrscr();
printf(“enter the no of test cases”);
scanf("%d",&a);
printf(“entrt the values of sides”);
scanf("%d%d%%d%d");
if(a==b&&c==d)
{
if(b==c)
printf(“no”);
else
printf(“yes”);
}
else if(b==c&&a==d)
{
if(a==c)
printf(“no”);
else
printf(“yes”);
else
printf(“no”);
getch();
}

@harsha_5

  1. Dont use void main. Its not allowed anymore I believe. Use int main().
  2. If you are serious about competitive programming, consider switching to c++. Its much more powerful.
  3. You dont have to print things like “enter the values” etc. Read output specifications of a problem carefully. Only print according to the given format. Like “yes” and “no” had to be uppercase.
  4. It can be a square. Nowhere in the problem was written otherwise.
  5. There are several beginner’s guide you can find by some googling. Read them

Exactly same solution i did…

your Editorials are not visible below the questions we need to find editorial in discussion part. kindly add a link below question its self

#include
using namespace std;
int main()
{
int a,b,c,d,t;
int n=0;
cin>>t;
for(int i=1;i<=t;i++)
{
cin>>a>>b>>c>>d;
if(a==b)
n++;

		if(a==c)
		n++;
	
		if(a==d)
		n++;
	
		if(b==c)
		n++;
		
		if(b==d)
		n++;
	
		if(c==d)
		n++;
		
	{	if(n==2)
				cout<<"YES\n";
		else
			cout<<"NO\n";
	}
		n=0;		
}
return 0;
} 

//what’s wrong with my code. I haven’t used sort function.

What if its a square? Square is a rectangle with length=breadth.