Объяснение:
using System;
namespace ConsoleApp2
{
class Program
static void Main(string[] args)
bool InArea = false;
Console.Write("R=");
double R = double.Parse(Console.ReadLine());
Console.Write("x=");
double x = double.Parse(Console.ReadLine());
Console.Write("y=");
double y = double.Parse(Console.ReadLine());
// Проверяем попадает ли в полукруг
if (x <= 0 && y >= 0 && x * x + y * y <= R * R) InArea = true;
// Проверяем попадает ли в первую половинку треугольника
// Уравнение прямой будет y=-2x
if (x > 0 && x <= R/2.0 && y >= -2*x && y<=0) InArea = true;
// Проверяем попадает ли во вторую половинку треугольника
// Уравнение прямой будет y=2x-2R
if (x > 0 && x <= R / 2.0 && y >= 2 * x - 2 * R && y <= 0) InArea = true;
if(InArea) Console.WriteLine("Точка принадлежит области");
else Console.WriteLine("Точка не принадлежит области");
Console.ReadLine();
}
Объяснение:
using System;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
bool InArea = false;
Console.Write("R=");
double R = double.Parse(Console.ReadLine());
Console.Write("x=");
double x = double.Parse(Console.ReadLine());
Console.Write("y=");
double y = double.Parse(Console.ReadLine());
// Проверяем попадает ли в полукруг
if (x <= 0 && y >= 0 && x * x + y * y <= R * R) InArea = true;
// Проверяем попадает ли в первую половинку треугольника
// Уравнение прямой будет y=-2x
if (x > 0 && x <= R/2.0 && y >= -2*x && y<=0) InArea = true;
// Проверяем попадает ли во вторую половинку треугольника
// Уравнение прямой будет y=2x-2R
if (x > 0 && x <= R / 2.0 && y >= 2 * x - 2 * R && y <= 0) InArea = true;
if(InArea) Console.WriteLine("Точка принадлежит области");
else Console.WriteLine("Точка не принадлежит области");
Console.ReadLine();
}
}
}
#include <iostream>
using namespace std;
int main() {
unsigned int n;
cout << "N = ";
cin >> n;
float a[n][n],
sum = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cout << "a[" << i
<< "][" << j
<< "] = ";
cin >> a[i][j];
sum += a[i][j];
}
}
float avg = sum / (n * n);
cout << "Среднее арифметическое - "
<< avg << ", начинаю замену...\n";
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (a[i][j] < 0) {
cout << "a[" << i
<< "][" << j
<< "] = " << a[i][j]
<< " < 0, заменяю на "
<< avg << "...\n";
a[i][j] = avg;
}
}
}
cout << "\nИзменённый массив:\n";
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cout << a[i][j];
if ( !(j == n - 1) ) cout << ' ';
}
if ( !(i == n - 1) ) cout << '\n';
}
return 0;
}
// #2
#include <iostream>
using namespace std;
const unsigned short int n = 7;
int main() {
int a[n][n],
max;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cout << "a[" << i
<< "][" << j
<< "] = ";
cin >> a[i][j];
}
}
max = a[0][0];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if ( (a[i][j] > max) && (i + j > n + 1) )
max = a[i][j];
}
}
cout << "Максимум ниже побочной диагонали: "
<< max;
return 0;
}