实验8.1 指针与数组(国外英文资料).docVIP

  • 2
  • 0
  • 约 23页
  • 2017-06-05 发布于河南
  • 举报
实验8.1 指针与数组(国外英文资料)

实验8.1 指针与数组 Experiment 8.1 and array Subject information table The name of the serial number title is numbered Circular movement (debug sample error08_1) Find the specified element in the array Use the selection method of functions 4 number off Circular movement (debug sample error08_1) # include stdio, h Int main (void) { Int I, m, n, k, j; Int a, [80]. Scanf ( % d % d ); For (I = 0; I n; I + +) Scanf ( % d, ); For (I = 0; I m + +) { K = a, [n - 1]. For (j = n minus 1; j ; j --) A [j] = a [j-1]; A [0] = k; } / * - the program fills in the blank and does not change the statement associated with the input output. Enter two positive integers n and m (1 m n = 10), and then input n integers, the number of line, to the right loop m a mobile location (removed from the right number again from moving from the left). The final output is n integers. Requirements definition and call the function mov (x, n, m) can realize the function of the circular movement, function parameters of x type is integer pointer, parameter n and m is of type int, function of type is void. Input/output example: in parentheses Input: 5, 3 (n = 5, m = 3) 1, 2, 3, 4, 5 (5 integers) Output: After move: 3, 4, 5, 1, 2 -- * / Printf ( After move: ); For (I = 0; I n; I + +) Printf ( % d , a [I]); Printf ( \ n ); Return 0; } Find the specified element in the array # include stdio, h Int main (void) { Int I, n, res, x; Int repeat, ri; Int a, [10]. Scanf ( % d , repeat); For (ri = 1;) Scanf ( % d , n); For (I = 0; I n; I + +) Scanf ( % d, ); Scanf ( % d , x); Res = 1; For (I = 0; I n; I + +) If (a [I] = = x) { Res = I; Break; } / * - the program fills in the blanks and does not change the statements associated with the input output. Enter a positive integer repeat (0 repeat 10) and do the following operation: Enter a positive integer n (1 n = 10), then input n integers into array a, enter an integer x, find x in array a, If you find the minimum index of the corresponding element, output Not

文档评论(0)

1亿VIP精品文档

相关文档