实验8.1 指针与数组(Experiment 8.1 pointer and array).doc
文本预览下载声明
实验8.1 指针与数组(Experiment 8.1 pointer and array)
Experiment 8.1 and array
Title information table
Title of the serial number title
1 circular movement (debug sample error08_1)
Find the specified element in the array
Use function selection to sort
4 number off
1 circular movement (debug sample error08_1)
# include stdio, h
Int main (void)
{
Int I, m, n, k, j.
Int a, [80].
The scanf ( % d % d , n, m);
For (I = 0; I n; I + +)
The scanf ( % d , a [I]);
For (I = 0; I m; i++) {
K = a, [n - 1].
For (j = n - 1; j 0; j --)
A [j] = a, [1].
A [0] = k;
}
/ * -- - program fill in the blank, dont change the statements associated with the input output.
Enter two positive integers n and m (1 m = 10), then enter n integers, line up these Numbers, and move the m position to the right (moving the number from the right to the left),
The last output is the NTH integer that is moved.
To define and call function mov (x, n, m) to realize the function of the above circular movement, the type of function parameter x is the integer pointer, the type of parameter n and m is int, and the type of function is void.
An example of the input output: an illustration in parentheses
Input:
3 (n = 5, 5 m = 3)
1, 2, 3, 4, 5 (5 integers)
Output:
After move: 3, 4, 5, 1, 2
-- * /
Printf ( After a 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].
The scanf ( % d , repeat);
For (ri = 1; ri = repeat; r + +) {
The scanf ( % d , n);
For (I = 0; I n; I + +)
The scanf ( % d , a [I]);
The scanf ( % d , x);
Res = 1;
For (I = 0; I n; i++)
If (a = = x [I]) {
Res = I;
Break;
}
/ * - fill in the blanks without changing 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 = 10), then input n integers into array a, then enter an integer x, find
显示全部