\ניסיתי להתנסות בזה על ידי הרצת הקוד בקומפיילר.
ובקונסול השחור הוא אומר לי להכניס a,b,c
אני מקיש a.והוא אומר לי 2 המספרים שווים.
איך אני בודק כל הפתרון של הקוד בקונסול שלב שלב?.
קוד:#include <stdio.h>#include <math.h> int main() { int a, b, c; int delta; double real, img; printf("Please enter a, b, c: "); scanf("%d%d%d", &a, &b, &c); /* Check if there are solutions */ if (a == 0 && b == 0 && c != 0) { printf("No solution.\n"); return 0; } /* Infinite number of solutions */ else if (a == 0 && b == 0 && c == 0) { printf("Infinite number of solutions.\n"); return 0; } /* One-degree equation? */ else if (a == 0) { printf("X = %.2lf\n", (double)-c / b); return 0; } /* Calculate delta */ delta = b*b - 4*a*c; /* If delta is positive - there are 2 solutions */ if (delta > 0) { printf("X1 = %.2lf\n", (-b + sqrt(delta))/(2*a)); printf("X2 = %.2lf\n", (-b - sqrt(delta))/(2*a)); return 0; } /* If delta is zero - there is one solution */ else if (delta == 0) { printf("X = %.2lf\n", (double)-b/(2*a)); return 0; } /* If delta is negative - the solutions belongs to



ציטוט ההודעה