Misol. Berilgan natural sonning barcha tub bo’luvchilarini toping;
namespace davronbek
{
internal class Program
{
static void Main(string[] args)
{
int n, k = 0;
Console.WriteLine("n=");
n=Convert.ToInt32(Console.ReadLine());
for(int i=2;i<=n ;i++)
{
if (n % i == 0)
{
for(int j=2;j<=Math.Sqrt(i);j++)
{
if(i % j == 0)
{
k++;
}
}
if(k == 0)
{
Console.WriteLine(i);
}
k = 0;
}
using System;
using static System.Console;
using static System.Math;
namespace davronbek
{
class Program
{
public static void boluvchi(int n)
{
while (n % 2 == 0) {
Write(2+" "); n /= 2;
}
for (int i = 3; i <= Sqrt(n); i++)
{
while (n % i == 0)
{
Write(i + " "); n /= i;
}
}
if (n > 2) Write(n);
}
static void Main(string[] args) {
Write("n ni kiriting: ");
int n = Convert.ToInt32(ReadLine()); boluvchi(n);
}
}
}
10.11kun
10.Bir o‘lchamli massivlar bilan ishlash.
11.Ko‘p o‘lchamli massivlar bilan ishlash.
int n=Convert.ToInt32(Console.ReadLine());
int[] a=new int[n];
for(int i=0; i{
a[i]=int.Parse(Console.ReadLine());
}
for (int i = 0; i < n; i+=2)
{
Console.Write(a[i]+" ");
}
Console.WriteLine();
for (int i = 1; i < n; i += 2)
{
Console.Write(a[i] + " ");
}
int n=Convert.ToInt32(Console.ReadLine());
int [] a=new int[n];
for(int i=0; i{
a[i]=Convert.ToInt32(Console.ReadLine());
}
bool b=false;
for (int i = 1; i < n-1; i++)
{
if (a[i] < a[i - 1] && a[i] < a[i + 1])
{
Console.WriteLine(a[i]);
b = true;break;
}
}
if (!b)
{
Console.WriteLine("lokal minimum mavjud emas");
}
int n=Convert.ToInt32(Console.ReadLine());
int[] a=new int[n];
int t = 0;
for (int i=0; i{
a[i]=Convert.ToInt32(Console.ReadLine());
}
double k = Math.Abs(a[0] - a[1]);
for (int i = 0; i < n-1; i++)
{
if (Math.Abs(a[i] - a[i+1]) < k)
{
k = Math.Abs(a[i] - a[i + 1]);
t = i;
}
}
Console.WriteLine(a[t]+" "+a[t+1]);
C++ dan C# dasturlash tiliga o’tkazildi.
int n = 3, m = 2;
int[,] a = new int[n,m];
int[,] b = new int[n,m];
int[,] c= new int[n,m];
int[,] d= new int[n*2,m*3];
int s = 0;
void son()
{
for (int i = 0; i < n * 2; i++)
{
for (int j = 0; j < m * 3; j++)
{
if (i < n && j < m)
{
s = a[i, j];
}
else if (i < n && j >= m && j < 2 * m)
{
s = b[i, j - m];
}
else
if (i < n && j >= m * 2 && j < 3 * m)
{
s = c[i, j - m * 2];
}
else if (i >= n && j < m)
{
s = b[i - n, j];
}
else if (i >= n && j >= m && j < 2 * m)
{
s = 0;
}
else if (i >= n && j >= n * 2 && j < 3 * m)
{
s = a[i - n, j - m * 2];
}
d[i, j] = s;
}
}
}
for (int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
Console.Write($"a[{i}{j}]=");
a[i,j] =Convert.ToInt32(Console.ReadLine());
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
Console.Write($"b[{i}{j}]=");
b[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
Console.Write($"c[{i}{j}]=");
c[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
son();
for (int i = 0; i < n*2; i++)
{
for (int j = 0; j < m*3; j++)
{
Console.Write(d[i,j]+" ");
}
Console.WriteLine();
}
int n, l=0;
n=int.Parse(Console.ReadLine());
int[] a=new int[n];
int [] b=new int[n];
for(int i = 0; i < n; i++)
{
Console.Write($"a[{i}]=");
a[i]=Convert.ToInt32(Console.ReadLine());
}
for(int k = 0; k < n; k++)
{
Console.Write($"b[{k}]=");
a[k]=Convert.ToInt32(Console.ReadLine());
}
for (int i = 0; i < n; i++)
{
l = a[i];
a[i] = b[i];
b[i]= l;
}
for (int k = 0; k < n; k++)
{
Console.Write($"a[{k}]={a[k]} ");
}
Console.WriteLine();
for (int k = 0; k < n; k++)
{
Console.Write($"b[{k}]={b[k]} ");
}
int n=Convert.ToInt32(Console.ReadLine());
double t;
double [] a=new double[n];
for (int i=0; i{
Console.Write($"a[{i}]=");
a[i]=double .Parse(Console.ReadLine());
}
for(int i=1;i{
t=(a[i]+a[i-1])/2.0;
a[i - 1] = t;
}
for (int i = 0; i < n; i++)
{
Console.Write($"a[{i}]={a[i]} ");
}
int m, n, k;
n=Convert.ToInt32(Console.ReadLine());
k=Convert.ToInt32(Console.ReadLine());
m=Convert.ToInt32(Console.ReadLine());
int [] a=new int[n+m];
for (int i=0; i{
Console.Write($"a[{i}]=");
a[i]=Convert.ToInt32(Console.ReadLine());
}
for(int i = n - 1; i >= k; i--)
{
a[i + m] = a[i];
a[i] = 0;
}
n += m;
for (int i = 0; i < n; i++)
{
Console.WriteLine(a[i]);
}
int n=Convert.ToInt32(Console.ReadLine());
int[] a=new int[n];
int min = 0, k = 0 ;
for (int i=0; i{
Console.Write($"a[{i}]=");
a[i]=Convert.ToInt32(Console.ReadLine());
}
for(int i = 0; i < n; i++)
{
min=a[i];
for(int j=i; j{
if (a[j] < min)
{
min = a[j];k = j;
}
}
a[k] = a[i];
a[i] = min;
}
for (int i = 0; i < n; i++)
{
Console.Write($"a[{i}]={a[i]} ");
}
int n=Convert.ToInt32(Console.ReadLine());
int[] a=new int[n];
int min;
for (int i=0; i{
Console.Write($"a[{i}]=");
a[i]=Convert.ToInt32(Console.ReadLine());
}
for(int i = 0; i < n; i++)
{
for(int j=0; j{
if (a[j] >a[i])
{
min = a[i];
a[i]=a[j];
a[j] = min;
}
}
}
for (int i = 0; i < n; i++)
{
Console.Write($"a[{i}]={a[i]} ");
}
int m, n, t = 0;
m=Convert.ToInt32(Console.ReadLine());
n=Convert.ToInt32(Console.ReadLine());
int[,] a = new int[m, n];
for (int i = 0; i < m; i++)
{
for(int j = 0; j < n; j++)
{
Console.Write($"a[{i}{j}]=");
a[i,j]= Convert.ToInt32(Console.ReadLine());
}
}
Console.WriteLine();
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
Console.Write(a[i,j]+" ");
}
Console.WriteLine();
}
Console.WriteLine();
double q=0;
for(int j = 0; j < n; j++)
{
q = 0;t = 0;
for(int i = 0; i < m; i++)
{
q += a[i, j];
}
q /= n;
for (int i = 0; i < m; i++)
{
if (q < a[i, j])
{
t++;
}
}
Console.Write(t+" ");
}
int m, n, t = 0;
m = Convert.ToInt32(Console.ReadLine());
n = Convert.ToInt32(Console.ReadLine());
int[,] a = new int[m, n];
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
Console.Write($"a[{i}{j}]=");
a[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n/2; j++)
{
t = a[i, j];
a[i, j] = a[i, n - 1 - j];
a[i, n - 1 - j] = t;
}
}
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
Console.Write(a[i,j]+" ");
}
Console.WriteLine();
}
12.Satrlar bilan ishlash. String turi.
using System;
namespace ConsoleApp38
{
class Program
{
static void Main(string[] args)
{
string s1, s2;
char c;
s1 = Console.ReadLine();
s2 = Console.ReadLine();
c = char.Parse(Console.ReadLine());
for(int i = 0; i < s1.Length; i++)
{
if (s1[i] == c)
{
Console.Write(s1[i]+s2);
}
else
{
Console.Write(s1[i]);
}
}
}
}
}
13.Metodlardan foydalanib dastur tuzish.
class programm
{
static int Digit(string k, int n)
{
if (k.Length < n)
{
return -1;
}
else
{
return k[n - 1]-48;
}
}
static void Main()
{
string k1, k2, k3;
int n;
k1 = Console.ReadLine();
n = int.Parse(Console.ReadLine());
int a = Digit(k1, n);
Console.WriteLine(a);
k2 = Console.ReadLine();
n = int.Parse(Console.ReadLine());
a = Digit(k2, n);
Console.WriteLine(a);
k3 = Console.ReadLine();
n = int.Parse(Console.ReadLine());
a = Digit(k3, n);
Console.WriteLine(a);
}
}
14.Rekursiv va qayta yuklanuvchi metodlarga oid misollar yechish
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static int factorial(int i)
{
int result;
if (i == 1)
return 1;
result = factorial(i - 1) * i;
return result;
}
static void Main(string[] args)
{
label1:
Console.WriteLine("sonni kiriting ");
try
{
int i = int.Parse(Console.ReadLine());
Console.WriteLine("{0}! = {1}", i, factorial(i));
}
catch (FormatException)
{
Console.WriteLine("sonni kiriting");
goto label1;
}
Console.ReadLine();
}
}
}
15.Params kalit so‘zidan foydalanib ko‘p parametrli metodlar e’lon qilish va ulardan foydalanish.
Masala sharti: Params kalit so’zidan foydalanib o’quvchi fanlarini yig’indisini hisoblash sinflar uchun;
using System;
namespace ParamsSample
{
public class Students
{
public static int TotalMarks(params int[] list)
{
int total = 0;
for (int i = 0; i < list.Length; i++)
total += list[i];
return total;
}
public static string AllSubjects(params string[] subjects)
{
System.Text.StringBuilder builder = new System.Text.StringBuilder();
for (int i = 0; i < subjects.Length; i++)
{
builder.Append(subjects[i]);
builder.Append(" ");
}
return builder.ToString();
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("3ta parametrli parametrlar");
int jami3 = Students.TotalMarks(8, 9, 8);
Console.WriteLine(jami3);
string[] subs = { "Ingliz tili", "O'qish", "Yozish" };
Console.WriteLine(Students.AllSubjects(subs));
Console.WriteLine("4ta parametrli parametrlar");
int[] marks = { 24, 22, 25, 21 };
int jami4 = Students.TotalMarks(marks);
string str4 = Students.AllSubjects("Matematika", "Ingliz tili", "San'at", "Ijtimoiy fanlar");
Console.WriteLine(jami4);
Console.WriteLine(str4.ToString());
Console.WriteLine("5ta parametrli parametrlar");
int jami5 = Students.TotalMarks(92, 90, 95, 91, 98);
string str5 = Students.AllSubjects(new string[] { "Matematika", "Ingliz tili", "San'at", "Ijtimoiy fanlar", "Sport zali" });
Console.WriteLine(jami5);
Console.WriteLine(str5.ToString());
Console.ReadKey();
}
}
}
16.Kortejlar.
Masala:Quyidagi kartejda berilgan sonlarni o’sish tartibida joylashtiring
int[] mas = { 5, 8, 1, 14, 7, 6 };
for (int i = 0; i < mas.Length - 1; i++)
{
for (int j = i + 1; j < mas.Length; j++)
{
if (mas[i] > mas[j])
{
(mas[i], mas[j]) = (mas[j], mas[i]);
}
}
}
for (int i = 0; i < mas.Length; i++)
{
Console.WriteLine(mas[i]);
}
class Program
{
static void Main(string[] args)
{
var (Ism, Fam, tugsana, tugjoy, yosh, semestr1, semestr2) = (("Furqat", "Zoxid", "Davronbek", "Suhrob", "Javohir", "Botir"), ("Abduraupov", "Begimov", "Isaqulov",
"O`rozov", "Sindarova", "Abdaliyev"), (18, 23, 25, 08, 12, 05), ("Jizzax", "Jizzax", "Samarqand",
"Toshkent", "Sirdaryo", "Samarqand"), (18, 19, 18, 17, 17, 18), (Matematikanaliz1: (7, (4, 5, 3, 4, 3, 5)), Chiziqlialgebra1: (5, (5, 5, 4, 4, 4, 5)), Diskret1: (5, (4, 4, 3, 0, 0, 3)),
Ingliztil1: (4, (4, 4, 0, 3, 4, 3)), Algoritm1: (5, (3, 4, 0, 3, 0, 3)), Tarix: (4, (4, 5, 3, 3, 3, 4))), (Matematikanaliz2: (7, (5, 5, 3, 3, 3, 4)), Chiziqlialgebra2: (5, (5, 5, 5, 5, 5, 5)), Diskret2: (4, (3, 4, 0, 0, 0, 3)),
Ingliztil2: (2, (4, 5, 0, 3, 4, 4)), Algoritm2: (4, (3, 3, 0, 0, 0, 0)), Rustili: (4, (4, 5, 3, 3, 3, 4)), Jtarbiya: (2, (5, 3, 4, 5, 0, 3))));
double a1,a2,a3,a4,a5,a6;
a1 = (semestr1.Matematikanaliz1.Item1 * semestr1.Matematikanaliz1.Item2.Item1 + semestr1.Chiziqlialgebra1.Item1 * semestr1.Chiziqlialgebra1.Item2.Item1 + semestr1.Diskret1.Item1 * semestr1.Diskret1.Item2.Item1 +
semestr1.Ingliztil1.Item1 * semestr1.Ingliztil1.Item2.Item1 + semestr1.Algoritm1.Item1 * semestr1.Algoritm1.Item2.Item1 + semestr1.Tarix.Item1 * semestr1.Tarix.Item2.Item1 + semestr2.Matematikanaliz2.Item1 *
semestr2.Matematikanaliz2.Item2.Item1 + semestr2.Chiziqlialgebra2.Item1 * semestr2.Chiziqlialgebra2.Item2.Item1 + semestr2.Diskret2.Item1 * semestr2.Diskret2.Item2.Item1 + semestr2.Ingliztil2.Item1 * semestr2.Ingliztil2.Item2.Item1 +
semestr2.Algoritm2.Item1 * semestr2.Algoritm2.Item2.Item1 + semestr2.Rustili.Item1 * semestr2.Rustili.Item2.Item1 + semestr2.Jtarbiya.Item1 * semestr2.Jtarbiya.Item2.Item1) / 60.0;
a2 = (semestr1.Matematikanaliz1.Item1 * semestr1.Matematikanaliz1.Item2.Item2 + semestr1.Chiziqlialgebra1.Item1 * semestr1.Chiziqlialgebra1.Item2.Item2 + semestr1.Diskret1.Item1 * semestr1.Diskret1.Item2.Item2 +
semestr1.Ingliztil1.Item1 * semestr1.Ingliztil1.Item2.Item2 + semestr1.Algoritm1.Item1 * semestr1.Algoritm1.Item2.Item2 + semestr1.Tarix.Item1 * semestr1.Tarix.Item2.Item2 + semestr2.Matematikanaliz2.Item1 *
semestr2.Matematikanaliz2.Item2.Item2 + semestr2.Chiziqlialgebra2.Item1 * semestr2.Chiziqlialgebra2.Item2.Item2 + semestr2.Diskret2.Item1 * semestr2.Diskret2.Item2.Item2 + semestr2.Ingliztil2.Item1 * semestr2.Ingliztil2.Item2.Item2 +
semestr2.Algoritm2.Item1 * semestr2.Algoritm2.Item2.Item2 + semestr2.Rustili.Item1 * semestr2.Rustili.Item2.Item2 + semestr2.Jtarbiya.Item1 * semestr2.Jtarbiya.Item2.Item2) / 60.0;
a3 = (semestr1.Matematikanaliz1.Item1 * semestr1.Matematikanaliz1.Item2.Item3 + semestr1.Chiziqlialgebra1.Item1 * semestr1.Chiziqlialgebra1.Item2.Item3 + semestr1.Diskret1.Item1 * semestr1.Diskret1.Item2.Item3 +
semestr1.Ingliztil1.Item1 * semestr1.Ingliztil1.Item2.Item3 + semestr1.Algoritm1.Item1 * semestr1.Algoritm1.Item2.Item3 + semestr1.Tarix.Item1 * semestr1.Tarix.Item2.Item3 + semestr2.Matematikanaliz2.Item1 *
semestr2.Matematikanaliz2.Item2.Item3 + semestr2.Chiziqlialgebra2.Item1 * semestr2.Chiziqlialgebra2.Item2.Item3 + semestr2.Diskret2.Item1 * semestr2.Diskret2.Item2.Item3 + semestr2.Ingliztil2.Item1 * semestr2.Ingliztil2.Item2.Item3 +
semestr2.Algoritm2.Item1 * semestr2.Algoritm2.Item2.Item3 + semestr2.Rustili.Item1 * semestr2.Rustili.Item2.Item3 + semestr2.Jtarbiya.Item1 * semestr2.Jtarbiya.Item2.Item3) / 60.0;
a4 = (semestr1.Matematikanaliz1.Item1 * semestr1.Matematikanaliz1.Item2.Item4 + semestr1.Chiziqlialgebra1.Item1 * semestr1.Chiziqlialgebra1.Item2.Item4 + semestr1.Diskret1.Item1 * semestr1.Diskret1.Item2.Item4 +
semestr1.Ingliztil1.Item1 * semestr1.Ingliztil1.Item2.Item4 + semestr1.Algoritm1.Item1 * semestr1.Algoritm1.Item2.Item4 + semestr1.Tarix.Item1 * semestr1.Tarix.Item2.Item4 + semestr2.Matematikanaliz2.Item1 *
semestr2.Matematikanaliz2.Item2.Item4 + semestr2.Chiziqlialgebra2.Item1 * semestr2.Chiziqlialgebra2.Item2.Item4 + semestr2.Diskret2.Item1 * semestr2.Diskret2.Item2.Item4 + semestr2.Ingliztil2.Item1 * semestr2.Ingliztil2.Item2.Item4 +
semestr2.Algoritm2.Item1 * semestr2.Algoritm2.Item2.Item4 + semestr2.Rustili.Item1 * semestr2.Rustili.Item2.Item4 + semestr2.Jtarbiya.Item1 * semestr2.Jtarbiya.Item2.Item4) / 60.0;
a5 = (semestr1.Matematikanaliz1.Item1 * semestr1.Matematikanaliz1.Item2.Item5 + semestr1.Chiziqlialgebra1.Item1 * semestr1.Chiziqlialgebra1.Item2.Item5 + semestr1.Diskret1.Item1 * semestr1.Diskret1.Item2.Item5 +
semestr1.Ingliztil1.Item1 * semestr1.Ingliztil1.Item2.Item5 + semestr1.Algoritm1.Item1 * semestr1.Algoritm1.Item2.Item5 + semestr1.Tarix.Item1 * semestr1.Tarix.Item2.Item5 + semestr2.Matematikanaliz2.Item1 *
semestr2.Matematikanaliz2.Item2.Item5 + semestr2.Chiziqlialgebra2.Item1 * semestr2.Chiziqlialgebra2.Item2.Item5 + semestr2.Diskret2.Item1 * semestr2.Diskret2.Item2.Item5 + semestr2.Ingliztil2.Item1 * semestr2.Ingliztil2.Item2.Item5 +
semestr2.Algoritm2.Item1 * semestr2.Algoritm2.Item2.Item5 + semestr2.Rustili.Item1 * semestr2.Rustili.Item2.Item5 + semestr2.Jtarbiya.Item1 * semestr2.Jtarbiya.Item2.Item5) / 60.0;
a6 = (semestr1.Matematikanaliz1.Item1 * semestr1.Matematikanaliz1.Item2.Item6 + semestr1.Chiziqlialgebra1.Item1 * semestr1.Chiziqlialgebra1.Item2.Item6 + semestr1.Diskret1.Item1 * semestr1.Diskret1.Item2.Item6 +
semestr1.Ingliztil1.Item1 * semestr1.Ingliztil1.Item2.Item6 + semestr1.Algoritm1.Item1 * semestr1.Algoritm1.Item2.Item6 + semestr1.Tarix.Item1 * semestr1.Tarix.Item2.Item6 + semestr2.Matematikanaliz2.Item1 *
semestr2.Matematikanaliz2.Item2.Item6 + semestr2.Chiziqlialgebra2.Item1 * semestr2.Chiziqlialgebra2.Item2.Item6 + semestr2.Diskret2.Item1 * semestr2.Diskret2.Item2.Item6 + semestr2.Ingliztil2.Item1 * semestr2.Ingliztil2.Item2.Item6 +
semestr2.Algoritm2.Item1 * semestr2.Algoritm2.Item2.Item6 + semestr2.Rustili.Item1 * semestr2.Rustili.Item2.Item6 + semestr2.Jtarbiya.Item1 * semestr2.Jtarbiya.Item2.Item6) / 60.0;
Console.WriteLine(" |" + " 1-semestr fanlari |" + " 2-semestr fanlari |"+"GPA");
Console.WriteLine("|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---");
Console.WriteLine("Familiya |" + "Ism |" + "Tug'sa|" + "Tug'ulgan joy|" + "Yoshi| " + "Matematikanaliz1|" + "Chiziqlialgebra1|" + " Diskret1|" + "Ingliztil1|" + "Algoritm1|" + " Tarix |" + "Matematikanaliz2|" +
"Chiziqlialgebra2|" + "Diskret2|" + " Ingliztil2|" + " Algoritm2|" + " Rustili|" + "Jtarbiya|");
Console.WriteLine("|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|");
Console.WriteLine(Fam.Item1 + " |" + Ism.Item1 + " |" + tugsana.Item1 + " |" + tugjoy.Item1 + " |" + yosh.Item1 + " |" + semestr1.Matematikanaliz1.Item2.Item1 + " |" + semestr1.Chiziqlialgebra1.Item2.Item1 +
" |" + semestr1.Diskret1.Item2.Item1 + " |" + semestr1.Ingliztil1.Item2.Item1 + " |" + semestr1.Algoritm1.Item2.Item1 + " |" + semestr1.Tarix.Item2.Item1 + " |" +
semestr2.Matematikanaliz2.Item2.Item1 + " |" + semestr2.Chiziqlialgebra2.Item2.Item1 + " |" + semestr2.Diskret2.Item2.Item1 + " |" + semestr2.Ingliztil2.Item2.Item1 +
" |" + semestr2.Algoritm2.Item2.Item1 + " |" + semestr2.Rustili.Item2.Item1 + " |" + semestr2.Jtarbiya.Item2.Item1 + " |" + $"{a1:F1}"); ;
Console.WriteLine(Fam.Item2 + " |" + Ism.Item2 + " |" + tugsana.Item2 + " |" + tugjoy.Item2 + " |" + yosh.Item2 + " |" + semestr1.Matematikanaliz1.Item2.Item2 + " |" + semestr1.Chiziqlialgebra1.Item2.Item2 +
" |" + semestr1.Diskret1.Item2.Item2 + " |" + semestr1.Ingliztil1.Item2.Item2 + " |" + semestr1.Algoritm1.Item2.Item2 + " |" + semestr1.Tarix.Item2.Item2 + " |" +
semestr2.Matematikanaliz2.Item2.Item2 + " |" + semestr2.Chiziqlialgebra2.Item2.Item2 + " |" + semestr2.Diskret2.Item2.Item2 + " |" + semestr2.Ingliztil2.Item2.Item2 +
" |" + semestr2.Algoritm2.Item2.Item2 + " |" + semestr2.Rustili.Item2.Item2 + " |" + semestr2.Jtarbiya.Item2.Item2 + " |"+$"{a2:F1}");
Console.WriteLine(Fam.Item3 + " |" + Ism.Item3 + " |" + tugsana.Item3 + " |" + tugjoy.Item3 + " |" + yosh.Item3 + " |" + semestr1.Matematikanaliz1.Item2.Item3 + " |" + semestr1.Chiziqlialgebra1.Item2.Item3 +
" |" + semestr1.Diskret1.Item2.Item3 + " |" + semestr1.Ingliztil1.Item2.Item3 + " |" + semestr1.Algoritm1.Item2.Item3 + " |" + semestr1.Tarix.Item2.Item3 + " |" +
semestr2.Matematikanaliz2.Item2.Item1 + " |" + semestr2.Chiziqlialgebra2.Item2.Item1 + " |" + semestr2.Diskret2.Item2.Item1 + " |" + semestr2.Ingliztil2.Item2.Item1 +
" |" + semestr2.Algoritm2.Item2.Item3 + " |" + semestr2.Rustili.Item2.Item3 + " |" + semestr2.Jtarbiya.Item2.Item3 + " |"+ $"{a3:F1}");
Console.WriteLine(Fam.Item4 + " |" + Ism.Item4 + " |" + tugsana.Item4 + " |" + tugjoy.Item4 + " |" + yosh.Item4 + " |" + semestr1.Matematikanaliz1.Item2.Item4 + " |" + semestr1.Chiziqlialgebra1.Item2.Item4 +
" |" + semestr1.Diskret1.Item2.Item4 + " |" + semestr1.Ingliztil1.Item2.Item4 + " |" + semestr1.Algoritm1.Item2.Item4 + " |" + semestr1.Tarix.Item2.Item4 + " |" +
semestr2.Matematikanaliz2.Item2.Item1 + " |" + semestr2.Chiziqlialgebra2.Item2.Item1 + " |" + semestr2.Diskret2.Item2.Item1 + " |" + semestr2.Ingliztil2.Item2.Item1 +
" |" + semestr2.Algoritm2.Item2.Item4 + " |" + semestr2.Rustili.Item2.Item4 + " |" + semestr2.Jtarbiya.Item2.Item4 + " |"+ $"{a4:F1}");
Console.WriteLine(Fam.Item5 + " |" + Ism.Item5 + " |" + tugsana.Item5 + " |" + tugjoy.Item5 + " |" + yosh.Item5 + " |" + semestr1.Matematikanaliz1.Item2.Item5 + " |" + semestr1.Chiziqlialgebra1.Item2.Item5 +
" |" + semestr1.Diskret1.Item2.Item5 + " |" + semestr1.Ingliztil1.Item2.Item5 + " |" + semestr1.Algoritm1.Item2.Item5 + " |" + semestr1.Tarix.Item2.Item5 + " |" +
semestr2.Matematikanaliz2.Item2.Item5 + " |" + semestr2.Chiziqlialgebra2.Item2.Item5 + " |" + semestr2.Diskret2.Item2.Item5 + " |" + semestr2.Ingliztil2.Item2.Item5 +
" |" + semestr2.Algoritm2.Item2.Item5 + " |" + semestr2.Rustili.Item2.Item5 + " |" + semestr2.Jtarbiya.Item2.Item5 + " |"+ $"{a5:F1}");
Console.WriteLine(Fam.Item6 + " |" + Ism.Item6 + " |" + tugsana.Item6 + " |" + tugjoy.Item6 + " |" + yosh.Item6 + " |" + semestr1.Matematikanaliz1.Item2.Item6 + " |" + semestr1.Chiziqlialgebra1.Item2.Item6 +
" |" + semestr1.Diskret1.Item2.Item6 + " |" + semestr1.Ingliztil1.Item2.Item6 + " |" + semestr1.Algoritm1.Item2.Item6 + " |" + semestr1.Tarix.Item2.Item6 + " |" +
semestr2.Matematikanaliz2.Item2.Item6 + " |" + semestr2.Chiziqlialgebra2.Item2.Item6 + " |" + semestr2.Diskret2.Item2.Item6 + " |" + semestr2.Ingliztil2.Item2.Item6 +
" |" + semestr2.Algoritm2.Item2.Item6 + " |" + semestr2.Rustili.Item2.Item6 + " |" + semestr2.Jtarbiya.Item2.Item6 + " |"+ $"{a6:F1}");
Console.WriteLine("-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
if (a1 >= 2.6)
{
Console.WriteLine(Fam.Item1+"|"+Ism.Item1+" |"+"kursdan kursga o'tdi");
}
else
{
Console.WriteLine(Fam.Item1 + " |" + Ism.Item1 + " |" + "kursdan kursga o'ta olmadi");
}
if (a2 >= 2.6)
{
Console.WriteLine(Fam.Item2 + " |" + Ism.Item2 + "|" + "kursdan kursga o'tdi");
}
else
{
Console.WriteLine(Fam.Item2 + "|" + Ism.Item2 + "|" + "kursdan kursga o'ta olmadi");
}
if (a3 >= 2.6)
{
Console.WriteLine(Fam.Item3 + "|" + Ism.Item3 + " |" + "kursdan kursga o'tdi");
}
else
{
Console.WriteLine(Fam.Item3 + " |" + Ism.Item3 + " |" + "kursdan kursga o'ta olmadi");
}
if (a4 >= 2.6)
{
Console.WriteLine(Fam.Item4 + " |" + Ism.Item4 + " |" + "kursdan kursga o'tdi");
}
else
{
Console.WriteLine(Fam.Item4 + " |" + Ism.Item4 + " |" + "kursdan kursga o'ta olmadi");
}
if (a5 >= 2.6)
{
Console.WriteLine(Fam.Item5 + " |" + Ism.Item5 + "|" + "kursdan kursga o'tdi");
}
else
{
Console.WriteLine(Fam.Item5 + " |" + Ism.Item5 + "|" + "kursdan kursga o'ta olmadi");
}
if (a6 >= 2.6)
{
Console.WriteLine(Fam.Item6 + " |" + Ism.Item6 + " |" + "kursdan kursga o'tdi");
}
else
{
Console.WriteLine(Fam.Item6 + " |" + Ism.Item6 + " |" + "kursdan kursga o'ta olmadi");
}
17 Mavzu. Sanab o‘tiluvchi tur.
Amallar bajarish;
using System;
namespace ConsoleApp40
{
class Program
{
enum Amallar
{
Qowiw, ayiriw, Kopaytiriw, bolish, sinus, Kosinus, Logarifm, ildiz, kvadrat, kub, qavskvadrat, modul, atan, sigx, ayirmaningkv
}
static void Bajariw(int a, int b, Amallar c)
{
switch (c)
{
case Amallar.Qowiw: Console.WriteLine(a + b); break;
case Amallar.Kopaytiriw: Console.WriteLine(a * b); break;
case Amallar.ayiriw: Console.WriteLine(a - b); break;
case Amallar.bolish: Console.WriteLine(a / b); break;
case Amallar.sinus: Console.WriteLine(Math.Sin(a)); break;
case Amallar.Kosinus: Console.WriteLine(Math.Cos(b)); break;
case Amallar.Logarifm: Console.WriteLine(Math.Log(a, b)); break;
case Amallar.ildiz: Console.WriteLine(Math.Sqrt(a)); break;
case Amallar.kvadrat: Console.WriteLine(Math.Sqrt(a)); break;
case Amallar.kub: Console.WriteLine(Math.Pow(a, 3)); break;
case Amallar.qavskvadrat: Console.WriteLine(Math.Pow((a + b), 2)); break;
case Amallar.ayirmaningkv: Console.WriteLine(Math.Pow((a - b), 2)); break;
case Amallar.modul: Console.WriteLine(Math.Abs(b)); break;
case Amallar.atan: Console.WriteLine(Math.Atan(a)); break;
case Amallar.sigx: Console.WriteLine(Math.Asinh(b)); break;
}
}
static void Main(string[] args)
{
int a, b;
Console.Write("a=");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("b=");
b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("----------------------------------------------");
Console.WriteLine(" T/R |" + " AMALLAR | " + " NATIJA");
Console.WriteLine("----------------------------------------------");
Console.Write(" 1 | " + Amallar.Qowiw + " | "); Bajariw(a, b, Amallar.Qowiw);
Console.WriteLine("----------------------------------------------");
Console.Write(" 2 | " + Amallar.Kopaytiriw + " | "); Bajariw(a, b, Amallar.Kopaytiriw);
Console.WriteLine("----------------------------------------------");
Console.Write(" 3 | " + Amallar.ayiriw + " | "); Bajariw(a, b, Amallar.ayiriw);
Console.WriteLine("----------------------------------------------");
Console.Write(" 4 | " + Amallar.bolish + " | "); Bajariw(a, b, Amallar.bolish);
Console.WriteLine("----------------------------------------------");
Console.Write(" 5 | " + Amallar.sinus + " | "); Bajariw(a, b, Amallar.sinus);
Console.WriteLine("----------------------------------------------");
Console.Write(" 6 | " + Amallar.Kosinus + " | "); Bajariw(a, b, Amallar.Kosinus);
Console.WriteLine("----------------------------------------------");
Console.Write(" 7 | " + Amallar.Logarifm + " | "); Bajariw(a, b, Amallar.Logarifm);
Console.WriteLine("----------------------------------------------");
Console.Write(" 8 | " + Amallar.ildiz + " | "); Bajariw(a, b, Amallar.ildiz);
Console.WriteLine("----------------------------------------------");
Console.Write(" 9 | " + Amallar.kvadrat + " | "); Bajariw(a, b, Amallar.kvadrat);
Console.WriteLine("----------------------------------------------");
Console.Write(" 10 | " + Amallar.kub + " | "); Bajariw(a, b, Amallar.kub);
Console.WriteLine("----------------------------------------------");
Console.Write(" 11 | " + Amallar.qavskvadrat + " | "); Bajariw(a, b, Amallar.qavskvadrat);
Console.WriteLine("----------------------------------------------");
Console.Write(" 12 | " + Amallar.ayirmaningkv + "| "); Bajariw(a, b, Amallar.ayirmaningkv);
Console.WriteLine("----------------------------------------------");
Console.Write(" 13 | " + Amallar.modul + " | "); Bajariw(a, b, Amallar.modul);
Console.WriteLine("----------------------------------------------");
Console.Write(" 14 | " + Amallar.atan + " | "); Bajariw(a, b, Amallar.atan);
Console.WriteLine("----------------------------------------------");
Console.Write(" 15 | " + Amallar.sigx + " | "); Bajariw(a, b, Amallar.sigx);
Console.WriteLine("----------------------------------------------");
Console.WriteLine();
}
}
}
2.Op kalit so’zi
Orqali s1 va s2 ustida amallar bajarish;
Console.Write("s1=");
s1 = Console.ReadLine(true).KeyChar;
Console.WriteLine(s1);
Console.Write("s2=");
s2 = Console.ReadLine(true).KeyChar;
Console.WriteLine(s2.);
Console.Write("Amal:");
op = Console.ReadLine(true).KeyChar;
Console.WriteLine(op);
switch (op) {
case '+':Write("Natija" + (s1 + s2-96));break;
case '-': Write("Natija" + (s1 -s2)); break;
case '*': Write("Natija" + ((s1-48) *( s2-48))); break;
case '/': Write("Natija" + ((s1-48) /(s2-48))); break;
}
}
Do'stlaringiz bilan baham: |