> Finding nearest point C++ Language | krehstorrs
NEW POST | Welcome to Krehstorrs Blog
Home » » Finding nearest point C++ Language

Finding nearest point C++ Language

Finding nearest point C++ Language - how do I make this? you can find here and you can make it differently, in a way to modify this code to make it better than this, you can develop your code hinggan can look natural ....

Finding nearest point C++ Language
Finding nearest point C++ Language


#include <iostream>
#include <math.h>

using namespace std;

struct Point{
       int x,y;
       };
       
void duaTitikTerdekat(Point p[], int n, Point &p1, Point &p2){
    double d,dmin,dmax,temp;
    int i,j;
    dmin=9999;
    for(i=1; i<=(n-1); i++){
             for(j=i+1; j<=n; j++){
             temp=((p[i].x - p[j].x)*(p[i].x - p[j].x))-((p[i].y - p[j].y)*(p[i].y - p[j].y));
             d=sqrt(temp);
             if(d<dmin){
                        dmin=d;
                        p1=p[i];
                        p2=p[j];
                        }
             }
             }
    
    }

int main(){
    Point p[100];
    int n;
    Point p1,p2;
    cout<<"Masukkan banyak titik : ";
    cin>>n;
    cout<<"Masukkan titik - titiknya : "<<endl;
    for(int i=0; i<n; i++){
            cout<<"Titik ["<<i+1<<"] : "<<endl;
            cout<<"x : "; cin>>p[i].x;
            cout<<"y : "; cin>>p[i].y;
            }
    duaTitikTerdekat(p,n,p1,p2);
    cout<<endl;
    cout<<"Dua titik terdekat = "<<endl;
    cout<<"Titik pertama = ( "<<p1.x<<" , " <<p1.y<<" )"<<endl;
    cout<<"Titik kedua = ( "<<p2.x<<" , " <<p2.y<<" )";
    cout<<endl;
    system("PAUSE");
    return 0;
    }
You have just read an article that category C Plus Plus by title Finding nearest point C++ Language. You can bookmark this page with the URL http://krehstorrs.blogspot.com/2013/05/finding-nearest-point-c-language.html Thank you!
Share this article :

1 comments:

 
Support : Home | Sitemap | Privacy | Link List
Copyright © 2013. krehstorrs - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger