NilufarBukhorova

Posted on

# Masala

N1-->
Ikki nuqta orasidagi masofani hisoblab beradigan funksiya tuzing.

• nomi: `distance`
• parametrlari: int aX, int aY, int bX, int bY
``````#include <iostream>
#include <cmath>

using namespace std;

float distance(int aX, int aY, int bX, int bY)
{
int a= aY - bY;
int b= aX - bY;

int cKvadrat = a*a + b*b;

int c = sqrt(cKvadrat); //square root

return c;
//return sqrt(pow(aY - bY,2)+ pow(aX - bY,2))
}

int main()
{
cout << distance(5,6,2,2);
return 0;
}
``````

N2-->
Berilgan nuqta aylana ichidami yo'qmi aniqlaydigan funksiya tuzing.

• nomi: pointIsInCircle
• parametrlar:
• aylana markazini anglatuvchi int cX, int cY
• nuqta koordinasini anglatuvchi int pX, int pY
• qaytarishi: berilgan nuqta aylana ichida bo'lsa `true` yo'qsa `false` qaytaradi.
• `yuqorida yaratilgan distance funksiyasidan foydalaning.`

``````#include <iostream>
#include <cmath>

using namespace std;
float distance(int aX, int aY, int bX, int bY)
{
int a= aY - bY;
int b= aX - bY;

int cKvadrat = a*a + b*b;

int c = sqrt(cKvadrat); //square root

return c;
//return sqrt(pow(aY - bY,2)+ pow(aX - bY,2))
}
bool pointIsInCircle(int cX, int cY, int cRadius, int pX, int pY)
{
return distance(cX, cY, pX, pY) < cRadius;
}

int main()
{
cout << pointIsInCircle(3,3,2,5,5) << endl;
return 0;
}
``````