/* Copyright (c) 2014, Yantai University School of Computer * All rights reserved. * File name: Test.cpp *: Liu Chang * completion date: 2014 months * Version number: v1.0 * * Problem Description: Using pointer access, from the keyboard to the array a[n] input n data (n less than 100), Then the value of the element is stored in reverse order and then output. * Input Description: A total of n+1 integers, enter the n value first, and then enter n integers; * Program output: n integers that are exactly the opposite of the input order.
#include <iostream>using namespace Std;const int N=100;int main () { int a[n],*p,*q,n; cin>>n; for (p=a; p<a+n; p++) cin>>*p; P=a; q=a+n-1; while (p<q) { int r=*p; *p=*q; *q=r; p++; q--; } for (p=a; p<a+n; p++) cout<<*p<< '; Cout<<endl;}
Operation Result:
16th Week on-machine practice project The output array in reverse order