#include "stdafx.h"
#include <iostream> //cin cout definitions
#include <stdio.h> //scanf printf definitions
#include <math.h> //library containing sqrt
usingnamespace std;
//Function prototype - Calculates the distance between coordinates
double distance(int x1, int x2, int y1, int y2, int x3, int y3);
int
main(){
int x1; //input - x coordinate of point A
int y1; //input - y coordinate of point A
int x2; //input - x coordinate of point B
int y2; //input - y coordinate of point B
int x3; //input - x coordinate of point C
int y3; //input - y coordinate of point C
int slope;
//Get coordinates x, y
printf("\nEnter two integers as the coordinates for the first point> \n");
cin >> x1 >> y1;
printf("\nEnter two integers as the coordinates for the second point> \n");
cin >> x2 >> y2;
printf("\nEnter two integers as the coordinates for the third point> \n");
cin >> x3 >> y3;
//Call distance and display results
printf("\nThe distance between Points 1 and 2 is: %d \n" );
printf("\nThe distance between Points 1 and 3 is: %d \n" );
printf("\nThe distance between Points 2 and 3 is: %d \n" );
} //end main
//Function definitions
double
distance(int x1, int x2, int y1, int y2, int x3, int y3) {
z = ((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
v = ((x3 - x1)*(x3 - x1) + (y3 - y1)*(y3 - y1));
w = ((x3 - x2)*(x3 - x2) + (y3 - y2)*(y3 - y2));
double distance_1 = sqrt(z);
double distance_2 = sqrt(v);
double distance_3 = sqrt(w);
}
/* double getDistance(struct Point a, struct Point b)
{
double distance;
distance = sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) *(a.y - b.y));
return distance;
} */
I'd suggest, don't try to handle three different points at the same time. Use a function which returns the distance between just two points, and call it several times if there are several points.
I also would think the commented-out struct Point could be usefully employed throughout the code.