6-7-kun
6-Mavzu:Chiziqli operatorlarni dasturlash. Math kutubxonasi. Math kutubxonasi funksiyalari yordamida chiziqli-matematik misollarning dasturini tuzish.
7-Mavzu:Shart operatorlari.
1.1 amaliy topshiriq
2. Quyidagi shartlar bajarilganda “rost”, aks holda “yolg‘on” qiymat qabul qiluvchi mantiqiy munosabatlar C++ tilida yozilsin:
a) k butun soni 7 ga bo‘linadi;
b) ax2+bx+c=0 tenglama haqiqiy ildizlarga ega emas;
d) (x,y) nuqta, markazi (1,0) nuqtada bo‘lgan r radiusli aylananing tashqarisida yotadi;
e) n natural soni – to‘liq kvadrat.
/// a)
//int k = Convert.ToInt32(Console.ReadLine());
////Console.WriteLine(k%7==0);
//if (k % 7 == 0)
//{
// Console.WriteLine("rost");
//}
//else
//{
// Console.WriteLine("yolg'on");
//}
// b)
//double D, a, b, c;
//a = Convert.ToInt32(Console.ReadLine());
//b = Convert.ToInt32(Console.ReadLine());
//c = Convert.ToInt32(Console.ReadLine());
//D = b * b - 4 * a * c;
//if (D < 0)
//{
// Console.WriteLine("ildizga ega emas");
//}
//else
//{
// Console.WriteLine("ildizga ega");
//}
// d)
//int x, y, r;
//x = Convert.ToInt32(Console.ReadLine());
//y = Convert.ToInt32(Console.ReadLine());
//r = Convert.ToInt32(Console.ReadLine());
//if (Math.Pow(x - 1, 2) + Math.Pow(y, 2) > r * r)
//{
// Console.WriteLine("nuqta tashqarida yotadi");
//}
//else
//{
// Console.WriteLine("nuqta tegishli");
//}
// e)
//int r = Convert.ToInt32(Console.ReadLine());
//if (Math.Sqrt(r) % 1 == 0)
//{
// Console.WriteLine("to'la kvadrat");
//}
//else
//{
// Console.WriteLine("to'la kvadrat emas");
//}
1.2 amaliy
19. Quyidagi shart bajarilganda t mantiqiy o‘zgaruvchisi true, aks holda false qiymatini o‘zlashtirsin:
a) x, y va z sonlar o‘zaro teng;
b) x,y va z sonlardan faqat ikkitasi o‘zaro teng;
d) x musbat son;
e) p soni q ga qoldiqsiz bo‘linadi (p va q-natural sonlar);
f) ax2+bx+c=0 tenglama bitta yechimga ega, bu yerda a,b va c o‘zgaruvchilar 0 bo‘lishi mumkin;
/// 18.a misol
//double x, y, z;
//x = Convert.ToDouble(Console.ReadLine());
//y= Convert.ToDouble(Console.ReadLine());
//z= Convert.ToDouble(Console.ReadLine());
//Console.WriteLine(x==y&&z==y);
// b)
//double x, y, z;
//x = Convert.ToDouble(Console.ReadLine());
//y = Convert.ToDouble(Console.ReadLine());
//z = Convert.ToDouble(Console.ReadLine());
//Console.WriteLine((x == y && y != z) || (x != y && y == z) || (x != y && x == z));
// d)
//int x = Convert.ToInt32(Console.ReadLine());
//Console.WriteLine(x>0);
// e)
//int p, q;
// p = Convert.ToInt32(Console.ReadLine());
// q= Convert.ToInt32(Console.ReadLine());
//Console.WriteLine(p%q==0);
// f)
//double D, a, b, c;
//a = Convert.ToInt32(Console.ReadLine());
//b = Convert.ToInt32(Console.ReadLine());
//c = Convert.ToInt32(Console.ReadLine());
//D = b * b - 4 * a * c;
//if (D ==0)
//{
// Console.WriteLine("yagona yechimga ega");
//}
//else
//{
// Console.WriteLine("yagona yechimga ega emas");
//}
2 -amaliy topshiriq
6. double x;
Console.Write("x= ");
x = Convert.ToDouble(Console.ReadLine());
if (-1 <= x && x <= 1)
{
Console.Write(Math.Atan(x)+Math.Sqrt(Math.Abs(x-2)));
}
if (x < -1)
{
Console.Write(Math.Pow(2.71,2)*Math.Cos(Math.PI*x));
}
if(x>1)
{
Console.Write(Math.Log(x-1)*Math.Sin(Math.PI*x/2));
}
18.
double x,a=5,b=5;
Console.Write("x= ");
x = Convert.ToDouble(Console.ReadLine());
if (1<= x && x <= 2)
{
Console.Write(a*x*x*Math.Log(x));
}
if (x <1)
{
Console.Write(1);
}
if(x>2)
{
Console.Write(Math.Exp(a*x)*Math.Cos(b*x));
}
3 - amaliy topshiriq
int a, b, c, d;
a = Convert.ToInt32(Console.ReadLine());
b= Convert.ToInt32(Console.ReadLine());
c = Convert.ToInt32(Console.ReadLine());
d = Convert.ToInt32(Console.ReadLine());
if (!(a == b && b == c && c == d))
{
if (a == b && b == c)
{
Console.WriteLine(4);
}
if (b == c && c == d)
{
Console.WriteLine(1);
}
if (a == c && c == d)
{
Console.WriteLine(2);
}
if (a == b & b == d)
{
Console.WriteLine(3);
}
}
else
{
Console.WriteLine("hammasi bir xil");
}
20-misol.
19. Tomonlari koordinata o‘qlariga parallel (perpendikulyar) bo‘lgan ikkita kvadratlar bosh diagnallarining koordinatalari bilan berilgan: (x y ) 1 1 va ( ) 2 2 x y - birinchi kvadrat; ( ) 3 3 va x4 y4 (x y ) -ikkinchi kvadrat. Agar kvadratlar o‘zaro kesishmasa 0, urunsa 1 va kesishsa 2 qiymati chop etilsin
using System;
namespace ConsoleApp34
{
class Program
{
static void Main(string[] args)
{
int x1, x2, x3, x4, y1, y2, y3, y4;
bool b = false;
x1 = Convert.ToInt32(Console.ReadLine());
x2= Convert.ToInt32(Console.ReadLine());
x3= Convert.ToInt32(Console.ReadLine());
x4= Convert.ToInt32(Console.ReadLine()); ;
y1= Convert.ToInt32(Console.ReadLine());
y2= Convert.ToInt32(Console.ReadLine());
y3= Convert.ToInt32(Console.ReadLine());
y4= Convert.ToInt32(Console.ReadLine());
if ((x1 == x3 || x1 == x4 || x2 == x4 || x2 == x3)&&(y1==y3||y1==y4||y2==y3||y2==y4))
{
Console.WriteLine(1);
}
else
if((x1 < x3 && x2 > x3 || x1 < x4 && x2 > x4 || x1 > x3 && x1 < x4 || x2 > x3 && x2 < x4)&& (y1 < y3 && y2 > y3 || y1 < y4 && y2 > y4 || y1 > y3 && y1 < y4 || y2 > y3 && y2 < y4))
{
Console.WriteLine(2);
}
else
{
Console.WriteLine(0);
}
}
}
}
Do'stlaringiz bilan baham: |