namespace Array_86
{
class Program
{
publicstatic void Main(string[] args)
{
int i=0,n,k,l=0;double [] m=new double[4];
Console.Write("Massivlar elementlari sonini kiriting: n=");
n=int.Parse(Console.ReadLine());
Console.Write("1<=k<=4 oraliqdagi k ni kiriting: ");
k=int.Parse(Console.ReadLine());
double [] a=new double [n];
for (i=0;i{
Console.Write("a["+(i+1)+"]=");
a[i]=Convert.ToDouble(Console.ReadLine());
if (ielse a[i-k]=a[i];
}
for (i=k;i>0;i--) a[n-i]=m[k-i];
for (i=0;iWrite(a[i]+" ");
Console.ReadKey();
}
}
}
Natija:
Array 87. o’lchamli massiv berilgan, barcha elementlari birinchi elementdan tashqari o’sish tartibida. Birinchi elementni yangi o’ringa ko’chirilsin natijada o’sish tartibida massiv hosil bo’lsin.
Dasturning blok sxemadagi algoritmi: Dasturning C# dagi ko’rinishi: using System;
namespace Array_87
{
class Program
{
public static void Main(string[] args)
{
int i=0,n,k=0;bool b=true;double c;
Console.Write("Massivlar elementlari sonini kiriting: n=");
n=int.Parse(Console.ReadLine());
double [] a=new double [n];
Console.Write("a["+(i+1)+"]=");
a[i]=Convert.ToDouble(Console.ReadLine());c=a[0];
for (i=1;i{
Console.Write("a["+(i+1)+"]=");
a[i]=Convert.ToDouble(Console.ReadLine());
if (a[0]>a[i]){k=i;b=false;}
}
if (!b){for (i=0;ielse Console.WriteLine("Massiv o'zi o'sish tartibida joylashgan.");
for (i=0;iWrite(a[i]+" ");
Console.ReadKey();
}
}
}
Natija:
Array 88. o’lchamli massiv berilgan, barcha elementlari oxirgi elementdan tashqari o’sish tartibida. Oxirgi elementni yangi o’ringa ko’chirilsin natijada o’sish tartibida massiv hosil bo’lsin.
Dasturning blok sxemadagi algoritmi: Dasturning C# dagi ko’rinishi: using System;
Dasturning blok sxemadagi algoritmi: Dasturning C# dagi ko’rinishi: using System;
namespace Array_90
{
class Program
{
public static void Main(string[] args)
{
int i,n,k;
Console.Write("Massivlar elementlari sonini kiriting: n=");
n=int.Parse(Console.ReadLine());
Console.Write("1<=k<="+n+" oraliqdagi k sonini kiriting: ");
k=int.Parse(Console.ReadLine());
double [] a=new double [n];
for (i=0;i{
Console.Write("a["+(i+1)+"]=");
a[i]=Convert.ToDouble(Console.ReadLine());
if (i>=k) a[i-1]=a[i];
}
for (i=0;iWrite(a[i]+" ");
Console.ReadKey();
}
}
}
Natija: