C 语言 解2元一次方程纠错~~

来源:百度知道 编辑:UC知道 时间:2024/09/23 19:30:48
无法编译,
显示数字上的错误后缀,以及a前缺少(;

希望大家能帮忙发现错误。最先能改得完全正确的可以得分。。。。

/////////////////////////////////////

#include <stdio.h>
#include <math.h>
#define TITLE "This is a program that solute the second order equation."

void main()
{
float a,b,c,t,l;

printf("%s\n",TITLE);

printf("**********************************\n");
printf("aX*X + bX + c = 0\n");
printf("**********************************\n");

printf("Please input the a, b, c:\n");
printf("a:\n");
scanf_s("%f",&a);
printf("b:\n");
scanf_s("%f",&b);
printf("c:\n");
scanf_s("%f",&c);

if ( a==0 )
{
if ( b==0 )
{
if ( c==0 )
printf("There are infinite solutions to X.\n");

printf("X1= %fi + (%f)\n",(l/(2*a)) ,((-b)/(2*a))); // 2a 漏 *
printf("X2= %fi + (%f)\n",(l/(-2*a)),((-b)/(2*a))); // 2a 漏 *

scanf_s("%f",&a);
printf("b:\n");
scanf_s("%f",&b);
printf("c:\n");
scanf_s("%f",&c);

若无 scanf_s, 用 scanf(...)

#include <stdio.h>
#include <math.h>
#define TITLE "This is a program that solute the second order equation."

int main(void)
{
float a,b,c,t,l;

printf( "%s\n",TITLE );

printf( "**********************************\n" );
printf( "aX*X + bX + c = 0\n" );
printf( "**********************************\n" );

printf( "Please input the a, b, c:\n" );
printf( "a:\n" );
scanf( "%f",&a );