Browse Source

Added files

master
Rainer Hihn 4 years ago
parent
commit
81090cf215
  1. 26
      main.c
  2. 40
      strecke.c

26
main.c

@ -0,0 +1,26 @@
/*
* Laenge einer Strecke im Raum
*
* Rainer Hihn
*/
#include "strecke.h"
int main(void)
{
/**
* Variablendeklaration
*/
struct point firstPoint;
struct point secondPoint;
printf("Entfernung berechnen \n");
firstPoint = readPoint();
secondPoint = readPoint();
printf("Die Entfernung von Punkt 1 nach Punkt 2 ist: %f \n", distance(firstPoint, secondPoint));
return 0;
}

40
strecke.c

@ -0,0 +1,40 @@
/**
* Funktionen von 'Laenge einer Strecke im Raum'
*
* Rainer Hihn
*/
#include "strecke.h"
struct point readPoint()
{
struct point userPoint;
printf("Bitte x-Koordinate eingeben \n");
scanf("%62f", &userPoint.rX);
printf("Bitte y-Koordinate eingeben \n");
scanf("%62f", &userPoint.rY);
printf("Bitte z-Koordinate eingeben \n");
scanf("%62f", &userPoint.rZ);
return userPoint;
}
float distance(struct point point1, struct point point2)
{
float rNewX = 0;
float rNewY = 0;
float rNewZ = 0;
float rDistance = 0;
rNewX = point1.rX - point2.rX;
rNewY = point1.rY - point2.rY;
rNewZ = point1.rZ - point2.rZ;
rDistance = sqrt((rNewX * rNewX) + (rNewY * rNewY) + (rNewZ * rNewZ));
return rDistance;
}
Loading…
Cancel
Save