ADVERTISEMENT

One of the works done by our Robotics and Machine Learning division,
SELF-LEVELING QUADCOPTER
Arduino based Quadcopter.
Self-leveling is acheived by the aligning the quadcopter using the readings from the gryo as well as the accelerometer.
A four channel RC transmitter is used to control the movement of the quadcopter when in flight. Kindly subscribe to our YouTube Channel and stay tuned.

Tuesday 26 April 2016

CSE1002:BONUS:SORT POINTS

CSE1002 Sort a Given Set of Points

    Design a OOP model to represent a point in a two dimensional space and overload the operators >>,<<, > and ==. Given 'n' points, design an algorithm and write a C++ code to sort them in desceding order. While sorting a point is said to be greater than the other based on their x-coordinate value. If value of x-coordinate is same for both the points then make a decision based on their value of y-coordinate.

==============================================================

 UML
:


CODE:
istream& operator>>(istream& in,point &p)
{
in>>p.x>>p.y;
return in;
}
ostream& operator<<(ostream& out,point& p)
{
out<<p.x<<endl<<p.y<<endl;
return out;
}
bool point::operator==(point& p)
{
return p.x==x&&p.y==y;
}
bool point::operator>(point& p)
{
if(p.x==x)
 return y>p.y;
return x>p.x;
}
void sort_Points(point *p,int s)
{
point temp;
for(int i=0;i<s;i++)
 for(int j=i+1;j<s;j++)
 if(*(p+j)>*(p+i))
 {temp=*(p+i);
 *(p+i)=*(p+j);
 *(p+j)=temp;}
}

1 comment:

  1. Casino of the Sky - Mapyro
    Mapyro. 1 Southwell Way, Glacford, Connecticut Address. 1.5m, Glacford, CT 경상남도 출장샵 06382 Address. 1.5m. Glacford, 서산 출장안마 Connecticut 06382 Address. 1.5m. Glacford, Connecticut 06382 Address. 1.5m. Glacford, Connecticut 06382 Address. 충청북도 출장샵 1.5m. 경상북도 출장안마 Glacford, 창원 출장샵 Connecticut 06382.

    ReplyDelete