c ++ simple function application

The following statement array:

int  a[]={1,2,3,4,5,6,7,8};

4 to find the location of the array to array a copy b, then a reversal of the contents of the array, and then find the position 4, the final output arrays a and b, respectively, content.

Source:

#include < iostream>

#include < algorithm>

#include <functional> // array of descending sorting and retrieval, with <functional> This header function

using namespace std;

void main()

{

  int a[] = { 1,2,3,4,5,6,7,8 }, b[8];

  int i;

  cout << "array a position" 4 "is:" << * find (a, a + 8, 4) << endl; // Find position 4

  int *x;

  x = find(a, a + 8, 4);

  cout << * x << endl; // * x value is also 4

  copy (a, a + 8, b); // array to array a copy b

  reverse_copy (b, b + 8, a); // the array b, the reverse replicated to a, a complete reversal

  cout << "array after a reversal, the position" 4 "is:" << find (a, a + 8, 4) << endl; // Find position at 4

  cout << "a digital content:" << endl;

  for (i = 0; i<8; i++)

    cout << a[i] << " ,";

  cout << "\ n Content array b:" << endl;

  for (i = 0; i<8; i++)

    cout << b[i] << " ,";

  system("pause");

}

operation result:

Guess you like

Origin www.cnblogs.com/duanqibo/p/11887387.html