Cod sursa(job #2639727)
Utilizator | Data | 3 august 2020 16:49:19 | |
---|---|---|---|
Problema | Subsir crescator maximal | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("scmax.in");
ofstream out("scmax.out");
int n,x,k,st[100],i;
int main()
{
in>>n;
in>>x;
st[++k]=x;
for(i=2;i<=n;i++)
{
in>>x;
if(x<st[k] && x>st[k-1])
st[k]=x;
else if(x>st[k])
st[++k]=x;
}
for(i=1;i<=k;i++)
out<<st[i]<<' ';
return 0;
}