我对整个编程都是新手,所以请耐心等待。我想制作一个可以计算二次轴和x轴之间面积的程序。现在我的代码只为函数设计,a 是积极的,c 是消极的。
#include <stdio.h>
int main()
{
float a;
float b;
float c;
float x; /* this is the zero that is to the right*/
float y; /* this is the zero that is to the left*/
float z;
{
printf("Consider the function ax^2 + bx + c\n");
printf("Enter the a value: \n");
scanf("%f",&a);
printf("Enter the b value: \n");
scanf("%f",&b);
printf("Enter the c value: \n");
scanf("%f", &c);
x = (( -b + sqrt(b*b - 4*a*c)) / (2*a));
y = (( -b - sqrt(b*b - 4*a*c)) / (2*a));
do {
z=(((y+0.01)-(y))*((a*(y*y))+(b*y)+(c)));
y+0.01;} while (x>y);
if (y>=x) {
printf("The area is %f", z);
}
问题是程序永远不会停止运行。我想做的是制作小方块并测量它们的面积(记住 LRAM 和 RRAM)。所以我在做的是(零+一点点)乘以y值(a *(y * y))+(b * y)+(c)))`
有小费吗?