#include <stdio.h>
#include <math.h>
int main (void)
{
int a, b, c;
printf("************************************************\nWelcome to the cubic root estimator.\nThis estimates the value of one root of\nf(x)=ax^3+bx^2+cx+d.\n************************************************\nEnter the coefficients in the form “a b c”:\n");
scanf("%d,%d,%d", &a, &b, &c);
if (powf(b,2)<4*a*c)
printf("Complex Roots – cannot estimate with this program\n");
else{
int x, y;
int arr[100];
for (x=-50; x<=50; x++)
y=(a*x*x)+(b*x)+c;
if (y==0)
printf("There is a root at: x =%d", x);
else {
int i;
for (i=0; i<100; i++)
arr[i]= x; /*array of the values of x that dont yield y=o*/
for (i=0; i<100; i++)
{if (arr[0]<arr[i])
arr[0]=arr[i];
printf("There is a root at: x =%d", arr[i]);
}
は、それはオーバープリントアウトし度も何度も 『51』「ルートを繰り返し51です?私はこのコードを実行すると
です。別名:形式 "abc": 'でスマート引用符を使用します:" abc ":" – chux
C is isコードブロックを中括弧で区切る必要があります。インデントは読みやすくするためのものです。ループ体は 'y'を計算する文だけから成り、' x'は51で 'y'はおそらく0ではないでしょう。 –
また、最後のループの後、' i'は100ですが 'arr [100] 'は有効な配列要素ではありません。境界を超えた要素です。 –