6. Berilgan to‘rt xonali son raqamlarining ko‘paytmasi topilsin.
6-topshiriq:
using System;
namespace Amaliyot
{
class Program
{
static void Main(string[] args)
{
int n;
Console.WriteLine("berilgan sonni kiriting:");
n = Convert.ToInt32(Console.ReadLine());
int a, b, c, d;
a = n % 10;
n = n / 10;
b = n % 10;
n = n / 10;
c = n % 10;
n = n / 10;
d = n % 10;
int S = a * b * c * d;
Console.WriteLine(S);
}
}
}
{
class Program
{
static void Main(string[] args)
{
double x, y;
Console.Write("x=");
x = Convert.ToDouble(Console.ReadLine());
Console.Write("y=");
y = Convert.ToDouble(Console.ReadLine());
bool a = (Math.Abs(x) <= 1) == (Math.Abs(y) >= 1);
bool b = (x * x + y * y <= 4) == (y <= x);
Console.WriteLine("a:" + a + " b:" + b);
}
}
}
using System;
namespace Amaliyot
{
class Program
{
static void Main(string[] args)
{
bool a, b,c;
Console.Write("a=");
a = Convert.ToBoolean(Console.ReadLine());
Console.Write("b=");
b = Convert.ToBoolean(Console.ReadLine());
Console.Write("c=");
c = Convert.ToBoolean(Console.ReadLine());
bool x = !(a || b) == (!a) && (!b);
bool y = a && (b || c) == (a && b) || (a && c);
Console.WriteLine("a-misol:" + x+ " b-misol:" + y);
}
}
}
2.2-misol:
Yechilishi:
using System;
namespace Amaliyot
{
class Program
{
static void Main(string[] args)
{
double x;
Console.Write("x=");
x = Convert.ToDouble(Console.ReadLine());
double y=0;
if(-2<=x && x < 2)
{
y+= x * x;
}
else if (x < -2)
{
y+= x * x + 4 * x + 5;
}
else if (x >= 2)
{
y+= 2 - x;
}
Console.WriteLine("y=" + y);
}
}
}
2.18-misol:
Yechilishi:
using System;
namespace Amaliyot
{
class Program
{
static void Main(string[] args)
{
double x;
Console.Write("x=");
x = Convert.ToDouble(Console.ReadLine());
double y=0; double a = 2; double b = 0.5;
if(x < 1)
{
y+= 1;
}
else if (1<=x && x<=2)
{
y+= a*x*x*Math.Log(x);
}
else if (x>2)
{
y+= Math.Exp(a*x)*Math.Cos(b*x);
}
Console.WriteLine("y=" + y);
}
}
}
3.1-misol:
Yechilishi:
using System;
namespace Amaliyot
{
class Program
{
static void Main(string[] args)
{
int a, b, c;
Console.Write("a=");
a = Convert.ToInt32(Console.ReadLine());
Console.Write("b=");
b = Convert.ToInt32(Console.ReadLine());
Console.Write("c=");
c = Convert.ToInt32(Console.ReadLine());
int y = 0;
if(a==b && b == c)
{
y += 3;
}
else if(a==b || b==c || a == c)
{
y += 2;
}
else if (a + b <= c)
{
y += 0;
}
else if (a + b > c)
{
y += 1;
}
Console.WriteLine("y="+y);
}
}
}
3.17-misol:
17. Natural n (n 9999 ) soni berilgan. Sonni to‘rt xonali deb hisobga olgan holda ushbu sonning palindrom ekanligi aniqlansin (chapdan va o‘ngdan bir xil o‘qiladigan sonlar, masalan, 1221, 5555,4444 sonlari palindrom sonlar hisoblanadi).
Yechilishi:
using System;
namespace Amaliyot
{
class Program
{
static void Main(string[] args)
{
int n;
Mine:
Console.Write("n=");
n = Convert.ToInt32(Console.ReadLine());
if(n>9999 && n<1000)
{
Console.WriteLine("bu son shartga mos emas! boshqattan urinib koring!");
goto Mine;
}
int x, y, z, w;
x = n % 10;
n = n / 10;
y = n % 10;
n = n / 10;
z = n % 10;
n = n / 10;
w = n % 10;
if (x * 10 + y == z + w * 10)
{
Console.WriteLine("bu son polindrom");
}
else
{
Console.WriteLine("bu son polindrom emas");
}
}
}
}
8-9 topshiriq
1-Amaliy
15-misol
using System;
using System.Collections;
namespace Amaliyot
{
class Program
{
static void Main(string[] args)
{
int n;
Console.Write("yilni kiriting:");
n = Convert.ToInt32(Console.ReadLine());
int s = Math.Abs(n-1984);
int a = s % 60;
int b = a % 12;
if (a <= 12)
{
Console.Write("yashil ");
switch (b)
{
case 1: Console.Write("sichqon "); break;
case 3: Console.Write("yolbars "); break;
case 4: Console.Write("quyon "); break;
case 5: Console.Write("ajdarho "); break;
case 6: Console.Write("ilon "); break;
case 7: Console.Write("ot "); break;
case 8: Console.Write("qo‘y "); break;
case 9: Console.Write("maymun "); break;
case 10: Console.Write("tovuq "); break;
case 11: Console.Write("it "); break;
case 0: Console.Write("to‘ng‘iz "); break;
case 2: Console.Write("sigir "); break;
}
}
else if(a > 12 && a <= 24)
{
Console.Write("qizil ");
switch (b)
{
case 1: Console.Write("sichqon "); break;
case 3: Console.Write("yolbars "); break;
case 4: Console.Write("quyon "); break;
case 5: Console.Write("ajdarho "); break;
case 6: Console.Write("ilon "); break;
case 7: Console.Write("ot "); break;
case 8: Console.Write("qo‘y "); break;
case 9: Console.Write("maymun "); break;
case 10: Console.Write("tovuq "); break;
case 11: Console.Write("it "); break;
case 0: Console.Write("to‘ng‘iz "); break;
case 2: Console.Write("sigir "); break;
}
}
else if (a > 24 && a <= 36)
{
Console.Write("sariq ");
switch (b)
{
case 1: Console.Write("sichqon "); break;
case 3: Console.Write("yolbars "); break;
case 4: Console.Write("quyon "); break;
case 5: Console.Write("ajdarho "); break;
case 6: Console.Write("ilon "); break;
case 7: Console.Write("ot "); break;
case 8: Console.Write("qo‘y "); break;
case 9: Console.Write("maymun "); break;
case 10: Console.Write("tovuq "); break;
case 11: Console.Write("it "); break;
case 0: Console.Write("to‘ng‘iz "); break;
case 2: Console.Write("sigir "); break;
}
}
else if (a > 36 && a <= 48)
{
Console.Write("oq ");
switch (b)
{
case 1: Console.Write("sichqon "); break;
case 3: Console.Write("yolbars "); break;
case 4: Console.Write("quyon "); break;
case 5: Console.Write("ajdarho "); break;
case 6: Console.Write("ilon "); break;
case 7: Console.Write("ot "); break;
case 8: Console.Write("qo‘y "); break;
case 9: Console.Write("maymun "); break;
case 10: Console.Write("tovuq "); break;
case 11: Console.Write("it "); break;
case 0: Console.Write("to‘ng‘iz "); break;
case 2: Console.Write("sigir "); break;
}
}
else if (a > 48 && a <= 60)
{
Console.Write("qora ");
switch (b)
{
case 1: Console.Write("sichqon "); break;
case 3: Console.Write("yolbars "); break;
case 4: Console.Write("quyon "); break;
case 5: Console.Write("ajdarho "); break;
case 6: Console.Write("ilon "); break;
case 7: Console.Write("ot "); break;
case 8: Console.Write("qo‘y "); break;
case 9: Console.Write("maymun "); break;
case 10: Console.Write("tovuq "); break;
case 11: Console.Write("it "); break;
case 0: Console.Write("to‘ng‘iz "); break;
case 2: Console.Write("sigir "); break;
}
}
Console.WriteLine("yil");
}
}
}
2-Amaliy
14-misol
24-misol
using System;
using System.Collections;
namespace Amaliyot
{
class Program
{
static void Main(string[] args)
{
int n;
Console.Write("n:");
n = Convert.ToInt32(Console.ReadLine());
int n1 = n;
string s=n.ToString();
int r = s.Length;
int[] f = new int[r];
for (int i = 0; i < f.Length; i++)
{
f[i] = n % 10;
n = n % 10;
}
int S = 0;
for (int i = 0; i < f.Length; i++)
{
S += f[i];
}
if (S == n1)
{
Console.WriteLine("Bu son mukammal son!!!");
}
else
{
Console.WriteLine("Bu son mukammal son emas!!!");
}
}
}
}