#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void distCalc(double *a, double *b, double *c) {
}
void usage(void) {
printf("Enter X1, X2 and X3 coordinates for Point A and B.\n"); printf("Example: pointdist 1 2 3 1 2 3\n"); }
void errorMessage(int a, int *b) {
if (a == 0 && *b < 7) {
printf("Too few arguments!\n"); usage();
}
if (a == 0 && *b > 7) {
printf("Too many arguments!\n"); usage();
}
if (a > 3 && *b == 7) {
printf("Invalid X%i coordinate for point B!\n", a
- 3); usage();
}
if (a > 0 && a < 4 && *b == 7) {
printf("Invalid X%i coordinate for point A!\n", a
); usage();
}
}
int main(int argc, char *argv[]) {
int i = 0;
double dist = 0;
double vectorA[3] = {0};
double vectorB[3] = {0};
errorMessage(&i, &argc);
for (i = 0; i < 3; i++) {
if (sscanf(argv
[i
+ 1], "%lf", &vectorA
[i
]) != 1) { errorMessage(i + 1, &argc);
}
if (sscanf(argv
[i
+ 4], "%lf", &vectorB
[i
]) != 1) { errorMessage(i + 4, &argc);
}
}
distCalc(vectorA, vectorB, &dist);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPG1hdGguaD4KCnZvaWQgZGlzdENhbGMoZG91YmxlICphLCBkb3VibGUgKmIsIGRvdWJsZSAqYykgewoJKmMgPSBzcXJ0KHBvdyhiWzBdIC0gYVswXSwgMikgKwoJCSAgcG93KGJbMV0gLSBhWzFdLCAyKSArCgkJICBwb3coYlsyXSAtIGFbMl0sIDIpKTsKfQoKdm9pZCB1c2FnZSh2b2lkKSB7CglwcmludGYoIkVudGVyIFgxLCBYMiBhbmQgWDMgY29vcmRpbmF0ZXMgZm9yIFBvaW50IEEgYW5kIEIuXG4iKTsKCXByaW50ZigiRXhhbXBsZTogcG9pbnRkaXN0IDEgMiAzIDEgMiAzXG4iKTsKCWV4aXQoMSk7Cn0KCnZvaWQgZXJyb3JNZXNzYWdlKGludCBhLCBpbnQgKmIpIHsKCWlmIChhID09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