Pagini recente » Cod sursa (job #1128058) | Cod sursa (job #2228941) | Cod sursa (job #1352042) | Cod sursa (job #1672464) | Cod sursa (job #7961)
Cod sursa(job #7961)
#include<fstream.h>
#define max 10001
long int a[max],n,i,k,ic,sf,j=1,min=1000000001,min1=-1000000001;
int main()
{
ifstream f("secventa.in");
ofstream g("secventa.out");
f>>n>>k;
for(i=1;i<=n;i++)
f>>a[i];
while(j<=n-k+1)
{
min=a[j];
for(i=j;i<j+k;i++)
if(a[i]<min)
min=a[i];
if(min>min1)
{
min1=min;
ic=j;
sf=j+k-1;
}
j++;
}
g<<ic<<" "<<sf<<" "<<min1;
return 0;
}