Massiv
35. n olchamli massiv berilgan. Uning lokal maksimumlari orasidan eng kichigi topilsin. (Agar bunday element bolmasa 0 chiqarilsin.)
Console.Write("toʻplam elementlar sonini kiriting : " );
int n = int.Parse(Console.ReadLine()),i=0,c=0,k=0,d=0;
int[ ] a = new int[n];
for(i=0;i{
Console.Write("a["+i+"] = ");
a[i]= int.Parse(Console.ReadLine());
}
for(i=0;i {if(a[i+1]a[i] && a[i+1]>a[i+2])
c++;
k=n-c;
int[] b = new int[k];
b[0]=a[0];
for(i=0;i{
if(a[i+1]a[i] && a[i+1]>a[i+2])
c++;
else
{ d++;
b[d] = a[i+1];
}
}
b[k-1]=a[n-1] ;
for(i=0;i{
if(b[i]>=b[i+1])
{
c=b[i];
b[i]=b[i+1];
b[i+1]=c;
}
else
c=b[k-1];
}
Console.WriteLine(c);
Do'stlaringiz bilan baham: |