Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <cmath>
- using namespace std;
- struct da{
- float x1;
- float y1;
- float x2;
- float y2;
- float vl;
- }point[100];
- float formula(int i){
- float c=sqrt(fabs((point[i].y1-point[i].y2)*(point[i].y1-point[i].y2)+(point[i].x1-point[i].x2)*(point[i].x1-point[i].x2)));
- return c;
- }
- void sort(int N){
- da ne;
- for(int i=N-1;i>=0;i--){
- for(int j=0;j<i;j++){
- if(point[j].vl>point[i].vl){
- ne=point[i];
- point[i]=point[j];
- point[j]=ne;
- }
- }
- }
- }
- int main(){
- int N;
- cin>>N;
- for(int i=0;i<N;i++){
- cin>>point[i].x1;
- cin>>point[i].y1;
- cin>>point[i].x2;
- cin>>point[i].y2;
- }
- cout<<"\n";
- for(int i=0;i<N;i++){
- point[i].vl=formula(i);
- }
- sort(N);
- for(int i=0;i<N;i++){
- cout<<point[i].x1<<" "<<point[i].y1<<"\n"<<point[i].x2<<" "<<point[i].y2<<" "<<point[i].vl<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement