Dasturlash asoslaridan berilgan topshiriqlar



Download 1,51 Mb.
Sana22.07.2022
Hajmi1,51 Mb.
#836045
Bog'liq
Dasturlash asoslaridan topshiriqlar


Dasturlash asoslaridan berilgan topshiriqlar.

9-misol: N elementda turadigan butun sonlardan iborat bir o’lchamli massiv berilgan. Massivning toq elementlari indekslarining kamayish tartibida va toq elementlar miqdorini chiqaring.


.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication53


{
class Program
{
static void Main(string[] args)
{
int M, N;
Console.WriteLine("Satrlar sonini kiriting: ");
M = int.Parse(Console.ReadLine());
Console.WriteLine("Ustunlar sonini kiriting: ");
N = int.Parse(Console.ReadLine());
//Console.WriteLine("K sonini kiriting:");
//int D = int.Parse(Console.ReadLine());
double[,] a = new double[M, N];
for (int i = 0; i < M; i++)
{
for (int j = 0; j < N; j++)
{
a[i, j] = double.Parse(Console.ReadLine());
}
}
for (int i = 1; i < M; i += 2)
{
Console.WriteLine("{0} satr: ", i+1);
for (int j = 0; j < N; j++)
{
Console.Write(a[i, j] + " ");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}

26-misol: O’lchami M*N bo’lgan matritsa berilgan. Elementlarning ko’paytmasi eng katta bo’lgan matritsaning no’merini toping va shu no’merning eng kattasini ko’paytmani toping.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication57


{
class Program
{
static void Main(string[] args)
{
int p = 0; int ind=0, max = 0, min = 0, maxi = 0;
int M = int.Parse(Console.ReadLine());
int N = int.Parse(Console.ReadLine());

int[,] A = new int[M, N];


for (int i = 0; i < M; i++)
{
for (int j = 0; j < N; j++)
{
A[i, j] = int.Parse(Console.ReadLine());
}
}
for (int i = 0; i < M; i++)
{
for (int j = 0; j < M; j++)
{
if ((i > 0) && (j == 0)) Console.WriteLine();
Console.Write(" " + A[i, j]);
}
}
Console.WriteLine();
for (int i = 0; i < M; i++)
{

for (int j = 0; j < N; j++)


{
p *= A[i, j];

}
if (i == 0) { max = p; min = p; } else min = p;


p = 1;
if (max >= min) { maxi = max; ind = i; }
else { maxi = min; ind = i; }
}
Console.WriteLine("Elementlari ko`paymasi eng katta satr qiymati {0} va satr nomeri {1}", maxi, ind+1);
Console.ReadKey();
}
}
}


43-misol: O’lchami MxN bo’lgan matritsa berilgan. Elementlari kamayish tartibda joylashgan matritsani toping.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication57


{
class Program
{
static void Main(string[] args)
{
int max = 0, min = 0; bool t = true;
int M = int.Parse(Console.ReadLine());
int N = int.Parse(Console.ReadLine());

int[,] A = new int[M, N];


for (int i = 0; i < M; i++)
{
for (int j = 0; j < N; j++)
{
A[i, j] = int.Parse(Console.ReadLine());
}
}
for (int i = 0; i < M; i++)
{
for (int j = 0; j < M; j++)
{
if ((i > 0) && (j == 0)) Console.WriteLine();
Console.Write(" " + A[i, j]);
}
}
Console.WriteLine();
Console.WriteLine("Kamayish tartibidagi satrlar");
for (int i = 0; i < M; i++)
{
for (int j = 0; j < N; j++)
{
if (i >= 0 && j == 0) { max = A[i, j]; min = A[i, j]; }
if (max >= A[i, j]) { t = true; max = A[i, j]; }
else { t = false; break; }
}
if(t)
{
for (int j = 0; j < N; j++)
{

Console.Write(" " + A[i, j]);


}
}
Console.WriteLine();
}

Console.ReadKey();


}
}
}


9- misol: A va B butun sonlari berilgan. Shartning to’g’riligini ko’rsating.


“A va B sonlarining hech bo’lmaganda birsi toq”
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication9


{
class Program
{
static void Main(string[] args)
{
int a, b;
bool m;
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
a = a % 2; b = b % 2;
m = ((a == 1) || (b == 1));
Console.WriteLine(m);
Console.ReadKey();
}
}
}

9-misol. Grafikda nuqtaning borligi yoki yo’qligini topish


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication9


{
class Program
{
static void Main(string[] args)
{
int x = int.Parse(Console.ReadLine());
int y = int.Parse(Console.ReadLine());
Boolean e = (0 <= x) && (x <= 6) && (0 <= y) && (y <= 6) && (y >= -2 * x + 4) && (y >= -x) && (y <= x) && (y <= -x + 6);
Console.WriteLine(e);
Console.ReadKey();

}


}
}

Matematik tizimlar fanidan berilgan topshiriqlar.


Grafik chizish 9-misol
1. y=((cos(x)-sin(x))/cos(x)+sin(x))

2. x=3t+1, y=t^3+2t



3.z = ln(x^2+y^2)

Tenglamani yechish
9. 3*x-14+e^x-e^-x x=[1,3]
Tenglamalar sistemasini yechish
9. x-2y+6z+t=88
Differentsiyal tenglamani yechish

y'=1+0.5*y*sin(x)-2y^2, y(0)=0



Matritsa 9-misol. A=(1 -3 2, 1 0 -4, -2 -5 1)

B=(1 3 -1 2, 2 0 3 2, 2 -2 1 2, 3 2 2 3, 1 1 -2 0)


Algoritmlash fanidan berilgan topshiriqlar


28-Misol: N elementdan iborat o dan farqli butun sonli massiv berilgan. Massivda toq va juft sonlar izma iz kelishini tekshiring. Agar izma izlik kelsa o ni bo’lmasa shu qoydani buzgan birinchi elementning no’merini chiqaring.


using System;


using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication17


{
class Program
{
static void Main(string[] args)
{
int n;
Console.Write("N: ");
n = int.Parse(Console.ReadLine());
int[] a = new int[n];
int i;
for (i = 0; i < n; ++i)
{
Console.Write("a[{0}] : ", i + 1);
a[i] = int.Parse(Console.ReadLine());
}
int temp = a[0] % 2;

for (i = 1; ((i < n) && (temp != a[i] % 2)); ++i)


{
temp = a[i] % 2;
}

if (i == n)


{
Console.Write("{0}\n", 0);
}
else
{
Console.Write("{0}\n", i + 1);
}
Console.ReadKey();
}
}



45-misol: Barcha elementlari o’sish yoki kamayish tartibida tartiblashtirilgan N elementdan iborat butun sonli A massiv berilgan. Berilgan massivda bir-biridan farqlanadigan elementlarning miqdarini aniqlang.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication9


{
class Program
{
static void Main(string[] args)
{
int M, m = 0, n = 0;
M = int.Parse(Console.ReadLine());
double[] a = new double[M];
for (int i = 0; i < M; i++)
{
a[i] = double.Parse(Console.ReadLine());
} for (int i = 0; i < M; i++)
{
Console.Write(" " + a[i]);
}
Console.WriteLine();
for (int i = 1; i < M; i++)
{
if (a[i - 1] == a[i]) n++;
}
Console.WriteLine("Bir-biridan farqlanadigan elementlar soni: " + (M - n));
Console.ReadKey();
}
}
}



62-misol: O’lchami N bo’lgan A massiv berilgan. Shu o’lchamda quyidagi qoyda bo’yicha yangi B massivni tuzing: BK element A massivdagi K dan N gacha no’merdagi elementlarning qo’shilishini toping.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication9


{
class Program
{
static void Main(string[] args)
{
int M, m = 0;
double n = 0;
M = int.Parse(Console.ReadLine());
double[] a = new double[M];
double[] b = new double[M];
for (int i = 0; i < M; i++)
{
a[i] = double.Parse(Console.ReadLine());
} for (int i = 0; i < M; i++)
{
Console.Write(" " + a[i]);
}
Console.WriteLine();
for (int i = 0; i < M; i++)
{
for (int j = i; j < M; j++)
{
n += a[j];
}
b[i] = n;
n = 0;
}
Console.WriteLine("B massiv: ");
for (int i = 0; i < M; i++)
{
Console.Write(" " + b[i]);
Console.ReadKey();
}
}
}
}

79-misol: O’lchami N bo’lgan massiv berilgan. Massivning hamma lokal maksimumlarini nolga aylantiring (ya’ni o’zining yonindagilaridan katta son).


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication9


{
class Program
{
static void Main(string[] args)
{
int M, m = 0;
double n = 0;
M = int.Parse(Console.ReadLine());
double[] a = new double[M];
double[] b = new double[M];
for (int i = 0; i < M; i++)
{
a[i] = double.Parse(Console.ReadLine());
} for (int i = 0; i < M; i++)
{
Console.Write(" " + a[i]);
}
Console.WriteLine();
for (int i = 1; i < M - 1; i++)
{
if (a[i] < a[i - 1] + a[i + 1]) { Console.Write(" " + a[i] * a[i]); }
}
Console.ReadKey();
}
}
}

96-misol: O’lchami N(>2) bo’lgan butun sonli massiv berilgan. Massivdan jup no’merli (2,4,…) barcha elementlarini o’chiring. Shart operatorini foydalanmasdan.


using System;


using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication9


{
class Program
{
static void Main(string[] args)
{
int M, m = 0;
double n = 0;
M = int.Parse(Console.ReadLine());
double[] a = new double[M];
double[] b = new double[M / 2];
for (int i = 0; i < M; i++)
{
a[i] = double.Parse(Console.ReadLine());
} for (int i = 0; i < M; i++)
{
Console.Write(" " + a[i]);
}
Console.WriteLine();
for (int i = 1, j = 0; i < M; i += 2, j++)
{
b[j] = a[i];
}
for (int i = 0; i < M / 2; i++)
{
Console.Write(" " + b[i]);
}
Console.ReadKey();
}
}
}



Download 1,51 Mb.

Do'stlaringiz bilan baham:




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish