> Program Finding Shortest Point In Dev C++ | krehstorrs
NEW POST | Welcome to Krehstorrs Blog
Home » , » Program Finding Shortest Point In Dev C++

Program Finding Shortest Point In Dev C++

Program Finding Shortest Point In Dev C++, Finding two points in the set have a short distance. By entering input with coordinates x and y, with a lot of points and how do I find the result. Let's look at programs.

To the program you can copy the following :

#include<iostream>//description of the calling cout and cin
#include<math.h>
#define SIZE 100

using namespace std;

struct Point{
      float x,y;
      };
      
void Cari2TitikTerdekat(Point p[], int n, Point &p1, Point &p2){
     float d, dmin;
     int i, j;
     
     dmin=9999;
     for(i=1;i<n;i++){
                      for(j=i+1; j<=n; j++){
                                 d=sqrt(pow((p[i].x-p[j].x),2)+pow((p[i].y -p[j].y),2));
                                 if(d<dmin){
                                            dmin=d;
                                            p1=p[i];
                                            p2=p[j];
                                            }
                                 }
                      }
     }


int main(int argc, char *argv[]){
    int n,a,b;
    Point p[SIZE];
    Point p1,p2;
    cout<<"Masukkan banyak titik : "; cin>>n;
    for(int i=1;i<=n;i++){
            cout<<"titik ["<<i<<"] x = "; cin>>p[i].x;
            cout<<"titik ["<<i<<"] y = "; cin>>p[i].y;
            }
    Cari2TitikTerdekat(p,n, p1, p2);
    cout<<"koordinat "<<p1.x<<","<<p1.y<<" dan "<<p2.x<<","<<p2.y; 
    cout<<endl;
    for(int i=1;i<=n;i++){
            if(p1.x==p[i].x && p1.y==p[i].y){
                          a=i;
                          }
            if(p2.x==p[i].x && p2.y==p[i].y){
                          b=i;
                          }
            }         
    cout<<"titiknya = "<<a<<" dan "<<b;
    cout<<endl;

    system("PAUSE");
    return EXIT_SUCCESS;
}

Screenshot of the results you can see below:

Program Finding Shortest Point In Dev C++
Program Finding Shortest Point In Dev C++

To download the script, click on this link
You have just read an article that category C Plus Plus / Programing by title Program Finding Shortest Point In Dev C++. You can bookmark this page with the URL http://krehstorrs.blogspot.com/2013/04/program-finding-shortest-point-in-dev-c.html Thank you!
Share this article :

6 comments:

  1. Congratulations.... Thank you so much for taking the time to share this exciting information.

    Ecommerce Website Development India

    ReplyDelete
  2. All the information of this blog is really useful for learn the programming languages and coding.I really glad to read this blog information.
    Web Design Company | Website Design Companies

    ReplyDelete
  3. I really grateful to this blog for getting the latest information about Gypsy and Traveller Sites.This is very helpful for people. Web Development Company Bangalore| Web Design Companies Bangalore|

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. I just keep visiting this blog from past two years. The posts here are unique and useful than other blog posts. Such a great info provided in this post. Keep providing useful post in this blog .I appreciate author for this valuable post.
    Culinary Schools in Dubai | Dubai Cooking Schools | Sugar craft courses | ICCA

    ReplyDelete
  6. I am always searching online for articles that can help me to improve my knowledge. There is clearly a lot to know about this. I think you made some good points in Features also. I don't have words to describe this blog. By the way you are running a great blog. So, please keep on update like this post.
    Engineering Colleges in Chennai, Mechanical Engineering Colleges in Chennai

    ReplyDelete

 
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