x
2
+
y
2
=
16
...
...
...
...
...
...
.
.
(
1
)
x + y = 4 (2)
rearrange (2) to y = 4 - x (could do x = 4 - y )
substitute y = 4 - x into (1)
hence:
x
2
+
(
4
−
x
)
2
=
16
⇒
x
2
+
16
−
8
x
+
x
2
=
16
and
2
x
2
−
8
x
+
16
−
16
=
0
⇒
2
x
2
−
8
x
=
0
factor and solve : 2x(x - 4 ) = 0
⇒
x
=
0
,
x
=
4
substitute these values into y = 4 - x , to find corresponding values of y.
x = 0 : y = 4 - 0 = 4 → (0 , 4)
x = 4 : y = 4 - 4 = 0 → (4 , 0 )
These are the points of intersection with the line x +y = 4 and the circle
x
2
+
y
2
=
16
Answer link
Объяснение:
using namespace std;
/*
* Сумма элементов массива
* [ 1, 2, 3] => 6
* [-5, 8, 2] => 5
*/
int arraySum(int a[], int s)
{
int ret = 0;
for (int i = 0; i < s; i++) {
ret += a[i];
}
return ret;
}
/*
* Определение, каких чисел больше в массиве.
* [-1, 2, 3] => "Положительных"
* [ 1, -2, -3] => "Отрицательных"
*/
const char* plusMinGreater(int a[], int s)
{
int plus = 0, minus = 0;
for (int i = 0; i < s; i++) {
if (a[i] > 0) plus++;
if (a[i] < 0) minus++;
}
return (plus > minus ?
"Положительных чисел больше" :
(plus < minus ?
"Отрицательных чисел больше" :
"Положителных и отрицательных поровну"));
}
/*
* Разница между максимальным и минимальным элементами.
* [5, 3, 2] => 5 - 2 = 3
*/
int maxMinDiff(int a[], int s)
{
int min = a[0], max = a[0];
for (int i = 1; i < s; i++) {
if (a[i] > max) max = a[i];
if (a[i] < min) min = a[i];
}
return max - min;
}
int main()
{
int n;
cout << "n = ";
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cout << "Число " << i << ": ";
cin >> a[i];
}
cout << plusMinGreater(a, n) << endl
<< "Сумма: " << arraySum(a, n) << endl
<< "Разница максимального и минимального элементов: "
<< maxMinDiff(a, n) << endl;
return 0;
}