AR2


TEST CASE 1 

INPUT
5
10
2
3
5
6
OUTPUT
6 5 3 2 10

TEST CASE 2 

INPUT
6
2
1
4
8
7
2
OUTPUT
2 7 8 4 1 2

#include <iostream>
using namespace std;
int main() {
 int MAX;
  cin>>MAX;
  int array[MAX], i, largest1, largest2;
  for(i=0;i<MAX;i++)
    cin>>array[i];
  largest1=array[0];
  largest2=array[MAX-1];
  cout<<largest2<<" ";
  for(i=MAX-2;i>=1;i--)
  {
    cout<<array[i]<<" ";
  }
  cout<<largest1;
 return 0;
}

Comments

Popular posts from this blog

AR1

SER12

AR15