C语言-分支结构程序设计练习(国外英文资料).docVIP

  • 15
  • 0
  • 约7.8千字
  • 约 23页
  • 2017-06-05 发布于河南
  • 举报

C语言-分支结构程序设计练习(国外英文资料).doc

C语言-分支结构程序设计练习(国外英文资料)

C语言-分支结构程序设计练习 The program fills in and does not change the statements associated with the input output. Enter a positive integer repeat (0 repeat 10) and do the following operation: The input parameter a, b, c, the quadratic equation, a * x * x + b * x + c = 0 root, the result is 2 decimal Numbers. The output USES the following statements: Printf ( zero parameter, 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 , (-b + SQRT (d))/(2 * a)); Printf ( x2 = % 0.2 f \ n , (-b-sqrt (d))/(2 * a)); Printf ( x1 = % 0.2 f + % 0.2 fi \ n , minus b/(2 * a), SQRT (-d)/(2 * a)); Printf ( x2 = % 0.2 f - % 0.2 fi \ n , minus b/(2 * a), SQRT (-d)/(2 * a)); Input/output example: in parentheses Input: 5 (repeat = 5) 0, 0 (a = 0, b = 0, c = 0) 0, 0, 1 (a = 0, b = 0, c = 1) 0, 2, 4 (a = 0, b = 2, c = 4) 2.1, 8.9, 3.5 (a = 2.1, b = 8.9, c = 3.5) 1, 2, 3 (a = 1, b = 2, c = 3) Output: The parameter is 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; Scanf ( % d , repeat); For (ri = 1;) Scanf (% lf % lf). * * * * * * * * * * * } } # include stdio, h H # include math.h Int main (void) { Int repeat, ri; Double a, b, c, d; Scanf ( % d , repeat); For (ri = 1;) Scanf (% lf % lf). * * * * * * * * * * * D is equal to b times b minus 4 times a times c. If (a = = 0) If (b = = 0) If (c = = 0) Printf ( zero parameter, meaningless! \ n ); Else printf ( a and b are 0, c is not 0, the equation is not set \ n ); Else printf ( x = % 0.2 f \ n , minus c/b); Else if (d, = 0) Printf ( x1 = % 0.2 f \ n , (-b + SQRT (d))/(2 * a)); Printf ( x2 = % 0.2 f \ n , (-b-sqrt (d))/(2 * a)); } The else {printf ( x1 = % 0.2 f + % 0.2 fi \ n , -b/(2 * a), SQRT (-d)/(2 * a)); Printf ( x2 = % 0.2 f - % 0.2 fi \ n , minus b

文档评论(0)

1亿VIP精品文档

相关文档