2级C语言上机题 1(国外英文资料).docVIP

  • 4
  • 0
  • 约1.15万字
  • 约 16页
  • 2017-06-05 发布于河南
  • 举报
2级C语言上机题 1(国外英文资料)

2级C语言上机题 1 A selection of test questions on the secondary C language Write function fun, which USES the simple iterative method shown below to solve the equation: a real root of cosine of x minus x = 0. Xn + 1 = cos (xn) iteration steps are as follows: (1) the initial value of x1 is 0.0; (2) x0 = x1, the value of x1 is given to x0; (3) x1 = cos (x0), find a new x1; (4) if the absolute value of x0 minus x1 is less than 0.000001, the execution step (5), otherwise the execution step (2); (5) the x1 is the actual root of the equation cosine of x, minus x is equal to 0, and it returns as a function. Double x1 = 0.0; The do {x0 = x1; X1 = cos (x0); } While (fabs (x0-x1) = 0.000001); Return the x; 2, write the function double fun, and its function is to calculate s by the following formula. The n is passed in through the form. 1, 1, 1, 1, 1 + S = ─ ─ - ─ ─ ─ ─ - ─ ─ +... ─ ─ ─ ─ ─ 1, 3, 5, 7, 2n + 1 Int I, j = 1; Double s = 0; For (I = 0; I = n; I + +) {s = s + 1.0 / (2 * I + 1) * j; J = - j; } * sn = s; Write the function double fun, which is the function of finding the value of P according to the following formula, which is returned by the function value. M and n are two positive integers and they want m n. M! P = ─ ─ ─ ─ ─ N! (m, n)! Double I = 1, x = 1, y = 1, z = 1, p = 0; For (I = 1;) For (I = 1;) For (I = 1; I = (m - n); P = x/(y * z); Return the p; Write function fun, and its function is to compute: s = [ln (1) + ln (2) + ln (3) +... + ln (m)] 0.5 The log (n) function in C is called ln (n). The log functions reference is: double log (double x); Double I, s = 0; For (I = 1; I = m; I + +) s = s + log (I); Return SQRT (s); Write the function double fun (double h), which functions: rounding and retaining two decimal places Long int I, j = 1; If (h 0) {j = -1; H = - h; } H = h * 100 + 0.5; I = h; H = I / 100.0; Return h * j; Write function fun. The function is to find the smallest number greater than t in the Fibonacci sequence, and the result is returned by the f

文档评论(0)

1亿VIP精品文档

相关文档