C语言-分支结构程序设计练习(C language - branch structure programming exercise).doc
文本预览下载声明
C语言-分支结构程序设计练习(C language - branch structure programming exercise)
The program fills in and does not change the statement associated with the input output.
Enter a positive integer repeat (0 repeat 10), repeat the following operation:
Input parameter a, b, c, solve for a quadratic equation a * x * x + b * x + c = 0 root, and the result is 2 decimal places.
The output USES the following statements:
Printf ( all parameters are zero, the equation is meaningless! \ n );
Printf ( a and b are 0, c is not 0, the equation is not set \ n );
Printf ( x = % 0.2 f \ n , - c/b);
Printf ( x1 = % 0.2 f \ n , (a - b + SQRT (d))/(2 * a));
Printf ( x2 = % 0.2 f \ n , (a - b - SQRT (d))/(2 * a));
Printf ( x1 = % 0.2 f + % 0.2 fi \ n , - b/a) (2 * SQRT (d)/(2 * a));
Printf ( x2 = % % 0.2 f - 0.2 fi \ n , - b/a) (2 * SQRT (d)/(2 * a));
An example of the input output: an illustration in parentheses
Input:
5 (repeat = 5)
= 0 0 0 0 (a, b = 0, c = 0)
= 0 0 0 1 (a, b = 0, c = 1)
= 0 0 2 4 (a, b = 2, c = 4)
= 2.1 2.1 8.9 3.5 (a, b = 8.9 a, c = 3.5)
1 2 3 (a = 1, b = 2, c = 3)
Output:
The parameters are zero, the equation is meaningless!
A and b are 0, c is not 0, the equation doesnt work
X = 2.00
X1 = 0.44
X2 = 3.80
X1 = 1.00 + 1.41 I
X2 = - 1.00-1.41 I
# include stdio, h
H # include math.h
Int main (void)
{
Int repeat, ri;
Double a, b, c, d;
The scanf ( % d , repeat);
For (ri = 1; ri = repeat; r + +) {
Lf the scanf ( % % % lf lf , a, b, c);
/ * -- -- -- -- -- -- -- -- - * /
}
}
# include stdio, h
H # include math.h
Int main (void)
{
Int repeat, ri;
Double a, b, c, d;
The scanf ( % d , repeat);
For (ri = 1; ri = repeat; r + +) {
Lf the scanf ( % % % lf lf , a, b, c);
/ * -- -- -- -- -- -- -- -- - * /
D = b * * a * b - 4 c.
If (a = = 0)
If (b = = 0)
If (c = = 0)
Printf ( all parameters are zero, the equation is meaningless! \ n );
The else printf ( a and b are 0, c is not 0, the equation is not set \ n );
Else printf ( x = % 0.2 f \ n , -c/b);
Else if (d = 0) {
Printf ( x1
显示全部