수학 모델을 요구하는 과제가 있습니다.하지만이 문제는 제 주요 기능의 일부입니다. 실행하면 항상 숫자를 스캔하는 데 어려움이 있습니다. 누군가 도움이 필요합니다. 나 확인해 봐. 고마워요C에서 포인터를 사용하는 데 문제가 있음
추신. 누군가이 메뉴를 종료하는 3을 입력하면 어떻게 할 수 있습니까? 내가 무슨 생각 exit(),하지만 여전히 나던 작품을 사용합니다. 여기
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int option =0;
double *x1, *x2,*y1, *y2, *x,*y;
double *slope;
display_menu();
scanf(" %d", &option);
if(option ==1)
{
printf("You choose to do the Two-point form. \n");
printf("Enter the x-y coordinates of the first point separate by a space=> ");
scanf("%lf","%lf", &x1,&y1);
printf("Enter the x-y coordinates of the second point separate by a space=> ");
scanf("%lf","%lf", &x2,&y2);
two_point_form(*x1,*y1,*x2,*y2); /* <<<--------this one is always wrong. T.T */
}
}
int two_point_form(double *x1, double *y1, double *x2, double *y2)
{
double slope, intecept;
printf("Two-point form: ");
printf(" (%lf-%lf)", *y2,*y1);
printf(" m = --------");
printf(" (%lf-%lf)", *x2-*x1);
slope = (*y2-*y1)/(*x2-*x1);
intecept = *y1-slope**x1;
printf("Slope-intecept form: y= %lfx+%lf", slope, intecept);
}