The request is pretty long:

Consider a sequence x1, x2, ..., xn consists of n distinct positive integers. A maximum sequence number

neighboring elements in string form xi xi 1, ..., x k-1, XK, XK 1, ..., x j (1≤i <k <j≤n) property that xi <xi 1 <. .. <xK-1 <xK> xK 1> ...> XJ, xK is called mountain top. Two mountain sequences have a common element in a row maximum. A mountain sequence has at least 3 elements. An example of a format string values 3 4 6 8 does not contain any sequence mountain, and one made with values 3 4 8 1 2 5 0 2 contains sequences mountain: 3 August 4 1 and 1 2 5 0.

After determining all sequences mountain peaks and their sequences are deleted from the mountain tops string and continue the procedure repeated with new determination sequences mountain peaks and their new string obtained. The procedure stops when the string is no longer any sequence administration.

Requirement

Write a program that reads numbers n, x1, x2, ..., xn and then determine:

a) the initial string sequences mountain;

b)the total number of mountain sequences obtained from the initial string to one that does not contain any sequence mountain;

c) number of items in the final string does not contain sequences mountain.

Entry data

Munte.in input file contains the first line number n, and the next line of natural numbers x1, x2, ..., xn separated two by two by one space.

Output data

Munte.out output file will contain the first line of a natural number as required) on the second line a natural number as required on the third line a natural number as required c).

Restrictions and specifications

3 ≤ n ≤ 100

0 ≤ xi ≤ 100000, 1 ≤ i ≤ n

Requirement for correct solution a) obtain 20% of the score. Requirement for correct solution B) obtain 40% of the score.

Requirement for fair c) obtain 40% of the score.

I hope you understand something, I translated it with Google,as I didn't have the time to translate it myself.

The program is created with Codeblocks, in C++.

#include <iostream>

#include <fstream>

using namespace std;

int v[50],n,i,nr,j,k,a[50],b,nr1,nr_sf;

int main()

{

fstream out("munte.out");

cout<<"Write the number of numbers that you will give! ";

cin>>n;

for (i=1;i<=n;i++)

{

cout<<"Number "<<i<<"=";

cin>>v[i];

}

for (i=2;i<n;i++)

{

j=i-1;

k=i+1;

if((v[i]>v[j]) and (v[i]>v[k]))

{

nr=nr+1;

a[i]=v[i];

}

}

nr_sf=nr_sf+nr;

out<<nr<<endl;

nr1=1;

do

{

for (i=2;i<n;i++)

{

v[i]=v[i]-a[i];

}

for (i=2;i<n;i++)

if(v[i]!=0)

{

cout<<v[i]<<" ";

}

cout<<"Write the number of numbers that were shown! ";

cin>>b;

cout<<"Write the numbers that were shown in the same order! ";

for (i=1;i<=b;i++)

{

cin>>v[i];

}

for (i=2;i<=b;i++)

{

nr1=0;

j=i-1;

k=i+1;

if((v[i]>v[j]) and (v[i]>v[k]))

{

nr1=nr1+1;

a[i]=v[i];

}

}

if(nr1==0)

{

out<<nr;

}

if(nr1!=0)

{

out<<nr1<<endl;

}

nr_sf=nr_sf+nr1;

}

while (nr1!=0);

out<<nr_sf;

return 0;

}

Sorry I couldn't attach the files, but I didn't know how.

**Edited by antoniu200, 03 March 2016 - 09:50 AM.**