自学了几天,自己写的,发现没有按照自己的思想运行(拼音亲请无视了)
目的求解:ax^2+bx+c=0
流程:

#include <stdio.h>
#include <math.h>
int main(void)
{
float a = 0;
float b = 0;
float c = 0;
float x1,x2;
float delta;
bool yon = 1;//yon = true
char jx = ' ';
printf("yi yuan er ci fang cheng qiu jie\n");
while(yon)
{
printf("xi shu a:\n");
scanf("%f",&a);//a = 1;
printf("xi shu b:\n");
scanf("%f",&b);//b = 5;
printf("xi shu c:\n");
scanf("%f",&c);//c = 66;
delta = b*b - 4*a*c;
if (delta > 0)
{
x1 = (-b + sqrt(delta)) / (2 * a);
x2 = (-b - sqrt(delta)) / (2 * a);
printf("you 2 ge jie:\nx1 = %f, x2 = %f",x1,x2);
printf("\n");
}
else if (delta == 0)
{
x1 = x2 = (-b) / (2 * a);
printf("you 1 ge jie:\nx1 = x2 = %f",x1);
printf("\n");
}
else
{
printf("wu jie!\n");
}
printf("shi fou ji xu(Y/N):\n");
scanf("%c",&jx);
/*
switch (jx)
{
case 'Y' : yon = true;break;
case 'N' : yon = false;break;
}
*/
if (jx == 'Y')
{
yon = true;
}
else if (jx == 'N')
{
yon = false;
}
}
return 0;
}


目的求解:ax^2+bx+c=0
流程:

#include <stdio.h>
#include <math.h>
int main(void)
{
float a = 0;
float b = 0;
float c = 0;
float x1,x2;
float delta;
bool yon = 1;//yon = true
char jx = ' ';
printf("yi yuan er ci fang cheng qiu jie\n");
while(yon)
{
printf("xi shu a:\n");
scanf("%f",&a);//a = 1;
printf("xi shu b:\n");
scanf("%f",&b);//b = 5;
printf("xi shu c:\n");
scanf("%f",&c);//c = 66;
delta = b*b - 4*a*c;
if (delta > 0)
{
x1 = (-b + sqrt(delta)) / (2 * a);
x2 = (-b - sqrt(delta)) / (2 * a);
printf("you 2 ge jie:\nx1 = %f, x2 = %f",x1,x2);
printf("\n");
}
else if (delta == 0)
{
x1 = x2 = (-b) / (2 * a);
printf("you 1 ge jie:\nx1 = x2 = %f",x1);
printf("\n");
}
else
{
printf("wu jie!\n");
}
printf("shi fou ji xu(Y/N):\n");
scanf("%c",&jx);
/*
switch (jx)
{
case 'Y' : yon = true;break;
case 'N' : yon = false;break;
}
*/
if (jx == 'Y')
{
yon = true;
}
else if (jx == 'N')
{
yon = false;
}
}
return 0;
}


