История изменений
Исправление
dikiy,
(текущая версия)
:
Вот. немного доработал твою программку:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char **argv)
{
double x1, y1, x2, y2, x3, y3, x4, y4, k1, k2, b1, b2;
// checking the sufficiency of the data
if (argc < 7) {
printf("usage: c90ab x1 y1 x2 y2 x3 y3\n");
return 1;
}
// data initialization
x1 = atof(argv[1]);
y1 = atof(argv[2]);
x2 = atof(argv[3]);
y2 = atof(argv[4]);
x3 = atof(argv[5]);
y3 = atof(argv[6]);
// check first exception
l=sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1))
if (l==0.0) {
printf("Error: line AB doesn't exists!\n");
return 0;
}
skalar_produkt=((x3-x1)*(x2-x1)+(y3-y1)*(y2-y1))/l;
x4=(x2-x1)*skalar_produkt+x1;
y4=(y2-y1)*skalar_produkt+y1;
printf("D (%lf , %lf)\n", x4, y4);
return 0;
}
Исправление
dikiy,
:
Вот. немного доработал твою программку:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char **argv)
{
double x1, y1, x2, y2, x3, y3, x4, y4, k1, k2, b1, b2;
// checking the sufficiency of the data
if (argc < 7) {
printf("usage: c90ab x1 y1 x2 y2 x3 y3\n");
return 1;
}
// data initialization
x1 = atof(argv[1]);
y1 = atof(argv[2]);
x2 = atof(argv[3]);
y2 = atof(argv[4]);
x3 = atof(argv[5]);
y3 = atof(argv[6]);
// check first exception
l=sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1))
if (l==0.0) {
printf("Error: line AB doesn't exists!\n");
return 0;
}
skalar_produkt=((x3-x2)*(x2-x1)+(y3-y2)*(y2-y1))/l;
x4=(x2-x1)*skalar_produkt+x1;
y4=(y2-y1)*skalar_produkt+y1;
printf("D (%lf , %lf)\n", x4, y4);
return 0;
}
Исправление
dikiy,
:
Вот. немного доработал твою программку:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char **argv)
{
double x1, y1, x2, y2, x3, y3, x4, y4, k1, k2, b1, b2;
// checking the sufficiency of the data
if (argc < 7) {
printf("usage: c90ab x1 y1 x2 y2 x3 y3\n");
return 1;
}
// data initialization
x1 = atof(argv[1]);
y1 = atof(argv[2]);
x2 = atof(argv[3]);
y2 = atof(argv[4]);
x3 = atof(argv[5]);
y3 = atof(argv[6]);
// check first exception
l=sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1))
if (l==0.0) {
printf("Error: line AB doesn't exists!\n");
return 0;
}
skalar_produkt=(x2*x1+y2*y1)/l;
x4=(x2-x1)*skalar_produkt+x1;
y4=(y2-y1)*skalar_produkt+y1;
printf("D (%lf , %lf)\n", x4, y4);
return 0;
}
Исправление
dikiy,
:
Вот. немного доработал твою программку:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char **argv)
{
double x1, y1, x2, y2, x3, y3, x4, y4, k1, k2, b1, b2;
// checking the sufficiency of the data
if (argc < 7) {
printf("usage: c90ab x1 y1 x2 y2 x3 y3\n");
return 1;
}
// data initialization
x1 = atof(argv[1]);
y1 = atof(argv[2]);
x2 = atof(argv[3]);
y2 = atof(argv[4]);
x3 = atof(argv[5]);
y3 = atof(argv[6]);
// check first exception
l=sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1))
if (l==0.0) {
printf("Error: line AB doesn't exists!\n");
return 0;
}
skalar_produkt=(x2*x1+y2*y1)/l;
x4=x2*skalar_produkt+x1;
y4=y2*skalar_produkt+y1;
printf("D (%lf , %lf)\n", x4, y4);
return 0;
}
Исходная версия
dikiy,
:
Вот. немного доработал твою программку:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char **argv)
{
double x1, y1, x2, y2, x3, y3, x4, y4, k1, k2, b1, b2;
// checking the sufficiency of the data
if (argc < 7) {
printf("usage: c90ab x1 y1 x2 y2 x3 y3\n");
return 1;
}
// data initialization
x1 = atof(argv[1]);
y1 = atof(argv[2]);
x2 = atof(argv[3]);
y2 = atof(argv[4]);
x3 = atof(argv[5]);
y3 = atof(argv[6]);
// check first exception
l=sqrt((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1))
if (l==0.0) {
printf("Error: line AB doesn't exists!\n");
return 0;
}
skalar_produkt=(x2*x1+y2*y1)/l;
x4=x2*skalar_produkt+x1;
y4=y2*skalar_produkt+y1;
printf("D (%lf , %lf)\n", x4, y4);
return 0;
}