* * Copyright (c) 2012, Computer College of Yantai University
* All rights reserved.
* Author: Liu Tongbin
* Date of Completion: November 24, 2012
* Version number: v1.0
* Input Description:
* Problem Description: Re-store the values in an array in reverse order. For example: The original is 6,5,4,3,2,1, request to 1,2,3,4,5,6
* problem-solving ideas: In the middle element as the center, the two sides of the symmetrical elements of the value interchange
* Program output:
* Problem Analysis: slightly
* algorithm design: slightly
* *
#include <iostream>
using namespace std;
int main ()
{
int a[10],i;
int temp;
cout<< "Please enter the original sequence (10 integers):" <<endl;
for (i=0;i<=9;i++)
{
cin>>a[i];
}
for (i=0;i<5;i++) //The key is this loop, which swaps the values of symmetric elements.
{
temp=a[i];
A[I]=A[10-I-1];
a[10-i-1]=temp;
}
cout<< "Sequence of Reverse discharge:" <<endl;
for (i=0;i<=9;i++)
{
cout<<a[i]<< "";
}
cout<<endl;
return 0;
}