12-amaliy topshiriq
using System;
namespace Amaliyot
{
class Program
{
static void Main(string[] args)
{
string S, S1;
Console.Write("S: ");
S = Convert.ToString(Console.ReadLine());
Console.Write("S1: ");
S1= Convert.ToString(Console.ReadLine());
int As = S.IndexOf(S1);
string AWS = S.Substring(0, As) + S.Substring(As+S1.Length);
Console.WriteLine(AWS);
}
}
}
13-amaliy topshiriq
using System;
namespace Amaliyot
{
class Program
{
static bool polindromtoq(string s)
{
int q = s.Length / 2;
string r = s.Substring(0, q+1);
string r1 = s.Substring(q);
bool g1 = r.CompareTo(r1)==0;
return g1;
}
static bool polindromjuft(string s)
{
int q = s.Length / 2;
string r = s.Substring(0, q);
string r1 = s.Substring(q);
bool g1 = r.CompareTo(r1)==0;
return g1;
}
static void Main(string[] args)
{
string S, S1, S2;
Console.Write("S: ");
S = Convert.ToString(Console.ReadLine());
Console.Write("S1: ");
S1 = Convert.ToString(Console.ReadLine());
Console.Write("S2: ");
S2 = Convert.ToString(Console.ReadLine());
int a = S.Length;
int a1 = S1.Length;
int a2 = S2.Length;
bool h, h1, h2;
if (a % 2 == 1)
{
h = polindromtoq(S);
}
else
{
h = polindromjuft(S);
}
if (a1 % 2 == 1)
{
h1 = polindromtoq(S1);
}
else
{
h1 = polindromjuft(S1);
}
if (a2 % 2 == 1)
{
h2 = polindromtoq(S2);
}
else
{
h2 = polindromjuft(S2);
}
Console.WriteLine(h);
Console.WriteLine(h1);
Console.WriteLine(h2);
}
}
}
using System;
namespace Amaliyot
{
class Program
{
static int mins(int n)
{
int[] a = new int[n];
for (int i = 0; i < a.Length; i++)
{
Console.Write("a[" + i + "]=");
a[i] = Convert.ToInt32(Console.ReadLine());
}
int min = a[0];
for (int i = 0; i < a.Length; i++)
{
if (a[i] < min)
{
min = a[i];
}
}
return min;
}
static void Main(string[] args)
{
int n1, n2, n3;
Console.Write("n1=");
n1 = Convert.ToInt32(Console.ReadLine());
Console.Write("n2=");
n2 = Convert.ToInt32(Console.ReadLine());
Console.Write("n3=");
n3 = Convert.ToInt32(Console.ReadLine());
int q1 = mins(n1);
int q2 = mins(n2);
int q3 = mins(n3);
Console.WriteLine("1- 2- 3- massivning eng kichik elementi:" + q1+" "+q2+" "+q3);
}
}
}
2-misol
using System;
namespace Amaliyot
{
class Program
{
static int maxs(int n)
{
int[] a = new int[n];
for (int i = 0; i < a.Length; i++)
{
Console.Write("a[" + i + "]=");
a[i] = Convert.ToInt32(Console.ReadLine());
}
int max = 0;
for (int i = 0; i < a.Length; i++)
{
if (a[i] > max)
{
max = a[i];
}
}
return max;
}
static void Main(string[] args)
{
int n1, n2, n3;
Console.Write("n1=");
n1 = Convert.ToInt32(Console.ReadLine());
Console.Write("n2=");
n2 = Convert.ToInt32(Console.ReadLine());
Console.Write("n3=");
n3 = Convert.ToInt32(Console.ReadLine());
int q1 = maxs(n1);
int q2 = maxs(n2);
int q3 = maxs(n3);
Console.WriteLine("1- 2- 3- massivning eng kichik elementi:" + q1+" "+q2+" "+q3);
}
}
}
Do'stlaringiz bilan baham: |