c语言编程怎么纠错,【C语言】一道纠错的题

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

共10处问题

#include

#include

#include

/* Define useful quantities */

#define ERROR 1E-6

#define SOLUTION_INTERSECT 1

#define SOLUTION_PARALLEL 2

#define SOLUTION_COINCIDENT 3

/* Define first line segment, by points */

#define A_X -2.0;

#define A_Y 3.0

#define B_X 2.0

#define B_Y -1.0

double main(int argc, char *argv[])

{

int validInput, solution_type;

/* Declare intersection point */

double I[2];

/* Declare all vectors, for clarity */

double a[2], b[2], c[2], d[2], b_minus_a[2], d_minus_c[2], c_minus_a[2]; d

ouble Denom, Numer1, Numer2, Line1_Par, Line2_Par;

/*********************** * Input / Validation ***********************/ /* Check numbers of arguments, and read input */

validInput = (argc = 5);

validInput = validInput && sscanf(argv[1], "%lf", &c[0]);

validInput = validInput && sscanf(argv[2], "%lf", &c[1]);

validInput = validInput && sscanf(argv[3], "%lf", &d[0]);

validInput = validInput && sscanf(argv[4], "%f", &d[1]);

/* For clarity assign fixed segment ends to an array */

a[1] = A_X; a[2] = A_Y; b[0] = B_X; b[1] = B_Y;

/* Check for intersection if input validated */ if(validInput)

{

/* Vector needed for a parametric description of line 1 */

b_minus_a[0] = b[0] - a[0]; b_minus_a[1] = b[1] - a[1];

/* Vector needed for a parametric description of line 2 */

d_minus_c[0] = d[0] - c[0]; d_minus_c[1] = d[1] - c[1];

/* Other useful vector differences */

c_minus_a[0] = c[0] - a[0]; c_minus_a[1] = c[1] - a[1];

/* Denominator, common to both equations of line parameters */

Denom = -b_minus_a[1] * d_minus_c[0] + b_minus_a[0] * d_minus_c[1];

/* Numerators 1 and 2 */

Numer1 = -d_minus_c[0] * c_minus_a[1] + c_minus_a[0] * d_minus_c[1];

Numer2 = c_minus_a[0] * b_minus_a[1] - b_minus_a[0] * c_minus_a[1];

if( (fabs(Denom) <= ERROR)&&(fabs(Numer1) <= ERROR)&&(fabs(Denom) <= ERROR) )

solution_type = SOLUTION_COINCIDENT;

else {

/* Calculate line paremters */

Line1_Par = Numer1 / Denom;

Line2_Par = Numer2 / Denom;

/* Point of intersection */

if( (Line1_Par >= 0)&&(Line1_Par <= 1)&&(Line2_Par >= 0)&&(Line2_Par <= 1) )

I[0] = a[0] + Line1_Par * b_minus_a[0];

I[1] = a[1] + Line1_Par * b_minus_a[1]; solution_type = SOLUTION_INTERSECT; } } /* Print appropriate message */

if(solution_type==SOLUTION_COINCIDENT)

printf("Line segments are coincident\n");

else if(solution_type==SOLUTION_PARALLEL)

printf("Line segments are parallel\n");

else if(solution_type==SOLUTION_INTERSECT)

printf("Line segments intersect at (%d, %lf)\n", I[0], I[1]);

else

printf("No intersection for these segments\n");

}

else

{

printf("*****************************************\n");

printf("* !!! User input error detected !!! *\n");

printf("* Execution method: prog2A a b c d *\n");

printf("* where a, b, c and d are real numbers *\n");

printf("*****************************************\n"); }

return(EXIT_SUCCESS);}

我找到的是 stdio.h

ERROR 1e-6

多了个分号

int main

然后就不太会了

希望大神帮忙

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值