我有一个任务要求我做一个数学模型,这是我主要功能的一部分,但是,当我运行它时,我总是无法扫描数字,我只需要有人帮我检查一下。谢谢你
PS如果有人输入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);
}