Pagini recente » Cod sursa (job #2076497) | Cod sursa (job #273651) | Cod sursa (job #1951852) | Cod sursa (job #2547597) | Cod sursa (job #2765668)
#include <stdlib.h>
#include <stdio.h>
int n, poz, pozmax;
int a[100001];
int x, xmax;
int main()
{
FILE* pf = fopen("scmax.in", "r");
fscanf(pf, "%d", &n);
x = 1;
xmax = 1;
for(int i = 0; i < n; ++i)
{
fscanf(pf, "%d", &(a[i]));
printf("%d\n", x);
if (x == 1)
{
++x;
poz = i;
}
else
{
if(a[i] == a[i - 1])
{
continue;
}
if(a[i] > a[i - 1])
{
++x;
}
else
{
if(x > xmax)
{
xmax = x;
pozmax = poz-1;
x = 1;
}
}
}
}
fclose(pf);
if(x > xmax)
{
xmax = x;
pozmax = poz-1;
x = 0;
}
pf = fopen("scmax.out", "w");
fprintf(pf, "%d\n", xmax);
while(xmax != 0 && pozmax <= n)
{
if(a[pozmax] == a[pozmax - 1])
{
pozmax++;
continue;
}
else
{
fprintf(pf, "%d ", a[pozmax]);
}
xmax--;
pozmax++;
}
fclose(pf);
return 0;
}