Sozdat odnomerniy massiv selix nechetnix chisel razmernosti n


Download 14.7 Kb.
Sana05.04.2023
Hajmi14.7 Kb.
#1273955
Bog'liq
osnova programirovaniye pr


//sozdat odnomerniy massiv selix nechetnix chisel razmernosti n
int n = int.Parse(Console.ReadLine());
int[] A = new int[n];
for (int i = 0; i A[i] = 2*i+ 1;
}
for (int i = 0; i < n; i++)
Console.WriteLine(A[i]+" ");
Console.ReadKey();

// zapolnit massiv dva stepeni n


int n = int.Parse(Console.ReadLine());
int[] a = new int[n];
for (int i = 0; i a[i] = (int)Math.Pow(2,i);
}
for (int i = 0; i Console.WriteLine(a[i]+" ");

// zapolnit massiv dva stepeni n pravilnoye


int n=int.Parse(Console.ReadLine());
int[] a=new int[n];
for (int i = 0; i < n; i++)
{
a[i] = (int)Math.Pow(2.0,i);

}
for (int i = 0; i < n; i++)


Console.WriteLine(i + "-" + a[i]);
// vivesti na ekran elementi massiva v obratnom poryadke
int n=int.Parse(Console.ReadLine());
int[] a=new int[n];
for (int i = 0; i < n; i++)
a[i] = (int)Math.Pow(2.0,i);
for (int i =(n-1); i>=0; i--)
Console.WriteLine(i + "-" + a[i]);

// fibanachi sonini ketma ketligining n-chi hadini topish


int n=int.Parse(Console.ReadLine());
int[] f=new int[n];
f[0]=1;
f[1] = 1;
for (int i = 2; i < n; i++){
f[i] = f[i - 1] + f[i - 2];
}
Console.WriteLine(f[n-1]);
Console.ReadKey();

// 8misol


int n = int.Parse(Console.ReadLine());
int[] a = new int[n];
for (int i = 0; i a[i] = int.Parse(Console.ReadLine());
}
int t=0;
for (int i = 0; i < n; i++)
{
if (a[i] % 2 == 1)
{
t++;
Console.Write(a[i] + " ");
}
}
Console.WriteLine();
Console.WriteLine("toq sonlar soni" +t);
// 9misol
int n = int.Parse(Console.ReadLine());
int[] a = new int[n];
for (int i = 0; i a[i] = int.Parse(Console.ReadLine());
}
int t=0;
for (int i =n-1; i>0; i--)
{
if (a[i] % 2 == 0)
{
t++;
Console.Write(a[i] + " ");
}
}
Console.WriteLine();
Console.WriteLine("juft sonlar soni: " +t);

Javobi Hello, World!barildi 10soni


1
2
3
4
5
6
7
8
9
10
10 8 6 4 2
juft sonlar soni: 5
Download 14.7 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling