Задача 1.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Koltsov
{
class Program
{
static void Main(string[] args)
{
double x,y;
int flag;
char rep = ' ';
do
{ Console.Clear();
Console.WriteLine(" Введите значение Х: ");
x = double.Parse(Console.ReadLine());
Console.WriteLine(" Введите значение У: ");
y = double.Parse(Console.ReadLine());
if (x >= -2 && x <= 2 && x * x + y * y <= 4 && y <= 2 && y >= -2) flag = 1;
else flag = 0;
Console.WriteLine(" Координаты точки по оси ОХ: " + x);
Console.WriteLine(" Координаты точки по оси ОУ: " + y);
Console.WriteLine(" Значение flag = " + flag);
Console.WriteLine(" Для продолжения нажмите У");
rep = char.Parse(Console.ReadLine());
} while (rep == 'y' || rep == 'Y');
}
}
}
Задача 2.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Вариант_14
{
class Program
{
static void Main(string[] args)
{
char rep;
do // начало цикла
{
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Green;
Double x, y;
int flag;
Console.WriteLine("введите абсцису точки: ");
x = double.Parse(Console.ReadLine());
Console.WriteLine("введите ординату точки: ");
y = double.Parse(Console.ReadLine());
if (Math.Pow(x, 2) + Math.Pow(y, 2) >= 8 &&
Math.Pow(x, 2) + Math.Pow(y, 2) <= 32) flag = 1;
else flag = 0;
Console.WriteLine(" flag=" + flag);
Console.WriteLine();
Console.WriteLine(" Для повтора выполнения программы введите 'u'");
rep = char.Parse(Console.ReadLine());
}
while (rep == 'u');
Console.ReadLine();
}
}
}
Задача 3.
using System;
using System.Collections;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Metod
{
public void send(double[,] a, int n, int m, double max, double min)
{
Random g=new Random();
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
a[i, j] = min + (max - min) * g.NextDouble();
}
public void print(double[,] a, int n, int m, string str)
{
for (int i = 0; i < n; i++, Console.WriteLine())
{
for (int j = 0; j < m; j++)
{
Console.Write(str, a[i, j]);
}
}
}
public ArrayList copy(double[,] a, int n, int m, out ArrayList d)
{
ArrayList d = new ArrayList();
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
if (a[i, j] < 0) d.Add(a[i, j]);
}
}
return d;
}
}
class Program
{
static void Main(string[] args)
{ Metod ob = new Metod();
int n, m;
string s1 = " {0,2} ";
string s2 = " {0,2} ";
Console.WriteLine("Введите кол-во строк массива: ");
n = int.Parse(Console.ReadLine());
Console.WriteLine("Введите кол-во столбцов массива: ");
m = int.Parse(Console.ReadLine());
double[,] mas = new double [n, m];
ob.send(mas, n, m, -12.4, 21.7);
ArrayList d = new ArrayList();
d.Add(ob.copy(mas, n, m, out d));
Console.ReadLine();
for (int i = 0; i < d.Count; i++ )
Console.Write(s2, d(i));
ob.print(mas, n, m, s1);
}
}
}