Amaliy matematika fakulteti 10-21 guruh talabasi Boyirov Ahmadning Algoritmdan Amaliy topshiriqlari:
Amaliy topshiriq 19;Variant 4
using System.IO;
using System.Collections;
class programm
{
static void Main()
{
/*Bir o`lchamli sonli massivning
minimum elеmеntini massivning
охirgi elеmеnti bilan o`rin
almashtirilsin.*/
ArrayList ahmad = new ArrayList();
int n, min = 0, k, m = 0;
Console.Write("n=");
n=Convert.ToInt32(Console.ReadLine());
int[] a = new int[n];
for (int i = 0; i < n; i++)
{
Console.Write($" a[{i}]=");
a[i]= Convert.ToInt32(Console.ReadLine());
}
min = a[0]; k= a[n-1];
for (int i = 0; i < n; i++)
{
if (min > a[i])
{
min = a[i];
m = i;
}
}
a[m]= k;
a[n - 1] = min;
for (int i = 0; i < n; i++)
{
ahmad.Add(a[i]);
}
foreach (int i in ahmad)
{
Console.WriteLine(i);
}
}
}
Amaliy topshiriq 20;Variant 4
using System.IO;
using System.Collections;
class programm
{
static void Main()
{
ArrayList ahmad = new ArrayList();
Console.WriteLine("qism satr:");
string s = Console.ReadLine();
Console.WriteLine("satr:");
string s1 = Console.ReadLine();
int k = 0, l = 0; bool b = false;
for (int i = 0; i < s1.Length; i++)
{
k = 0;
b = false;
if (s1[i] == s[0])
{
for (int j = 0; j < s.Length; j++)
{
if (s1[j + i] == s[j])
{
k++;
}
}
if (k == s.Length)
{
l++;
}
}
}
Console.WriteLine(l);
}
}
Amaliy topshiriq 21;Variant 4
Vazifa 1
using System;
class Program
{
static void Main(string[] args)
{
System.IO.FileInfo a = new System.IO.FileInfo(@"d:\\BMI.doc");
bool x = a.Exists;
if (x) Console.WriteLine("d: diskda BMI.doc fayli bor");
else Console.WriteLine("d: diskda BMI.doc fayli yo'q");
}
}
Vazifa 2 Misol 1
Dostları ilə paylaş: |