Is it possible to make a rectangle with given four edges as integers?

0 votes
asked in Coding(Hiring) by shivani
You are given four edges as integers.Your task is to tell whether it is possible to form a rectangle with these edges?

Example:
Input: 2,5,2,5
Output:Yes
Add question to:

1 Answer

0 votes
answered by shivani
 
Best answer

Compare any two edges, If they are equal then to make a rectangle other two edges should be equal.
 

#include<iostream>
using namespace std;
 
int main(){
 
int a,b,c,d;
cin>>a>>b>>c>>d;
//Check all possible combinations
if((a==b&&c==d)||(a==c&&b==d)||(a==d&&b==c))
	cout<<"YES"<<endl;
else
    cout<<"NO"<<endl;

return 0;
} 

 

...