[Cpp]/** Copyright (c) 2012, School of Computer Science, Yantai University * All rights reserved. * file name: test. cpp * Author: Fan Lulu * Completion Date: July 15, December 16, 2012 * version: v1.0 ** input Description: none * Problem description: sorting the Array Using pointers * program output: array * Problem Analysis: * Algorithm Design: omitted */www.2cto.com # include <iostream> using namespace std; int main () {void select_sort (int * p, int n ); // define the int a [10] = {5, 8, 6, 97, 13, 19}, I; select_sort (a, 10 ); // reference function cout <"the sorted array is:" <endl; for (I = 0; I <10; I ++) // output function cout <<A [I] <''; cout <endl; return 0;} // The sorting Function Code void select_sort (int * p, int n) // use the pointer variable as the shape parameter {int I, j, t, k; // The loop of I (the first loop) starts from 0. By the end of The N-2, because the n-2 is compared with n-1, there is no need to loop to n. For (I = 0; I <n-1; I ++) {// assign the I value to k, so that the following sorting starts from I, and the preceding I is no longer required. K = I; // the cycle of j (Layer 2 loop) starts from I + 1 to n-1. Sort the results one by one. For (j = I + 1; j <n; j ++) // if the last number is greater than the previous one, assign j to k if (* (p + j)> * (p + k) k = j ;. // Sort and use pointers to receive array addresses. T = * (p + k); * (p + k) = * (p + I); * (p + I) = t ;}}