1. How to exchange values of two numbers
Void swap (int * a, int * B)
{
Int TEP = * A; // * A is actually the value of primary function a, and a is the address of primary function a's value.
* A = * B;
* B = TEP;
}
2. How to sort two-dimensional array Functions
Void DESC (INT (* A) [10], int I ){
// In this way, you can directly use the [I] [J] operation in this function, just like in the main function.
// Int (* A) [10] indicates a two-dimensional array with 10 columns. Then, write DESC (A, 5) in the main function ), this is a two-dimensional array with 5 rows.
For (INT n = 0; n <5; n ++)
For (Int J = 0; j <10; j ++)
{
If (a [n] [J] <a [n] [J + 1]) // you can determine the size. If the size is small, you can change the position of the backend.
Swap (& A [I] [J], & A [I] [J + 1]); // call the previous function to implement value exchange. Here is the address passed in, not a value.
}
}
* P: the number of pointers is the same. The number of (n-1) * after the first pointer is the address. Only the first pointer represents the pointer.
* ** P actually points to an address.
}