Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Z_2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Title = "Дана точка на плоскости с координатами (х, у).Узнать где она лежит.";
- Console.WriteLine("плоскость ограничена фигурой: \n x > -15, \n y > -15, \n x < 0, \n y < 0;");
- int exit = 1;
- while (exit == 1)
- {
- Console.Write("Введите x: ");
- string x1 = Console.ReadLine();
- x1 = x1.Trim();
- check(x1);
- double x = double.Parse(x1);
- Console.Write("Введите y: ");
- string y1 = Console.ReadLine();
- while (IsDigit(y1) != true)
- check(y1);
- double y = double.Parse(y1);
- if (x > -15 && y > -15 && x < 0 && y < 0)
- {
- Console.WriteLine("точка({0},{1}) находится вне фигуры", x, y);
- }
- else
- {
- if (x == -15 && y <= 0 && y >= -15 || x == 0 && y <= 0 && y >= -15 || y == -15 && y <= 0 && y >= -15 || y == 0 && x <= 0 && x >= -15)
- {
- Console.WriteLine("точка ({0},{1}) лежит на границе фигуры", x, y);
- }
- else
- {
- Console.WriteLine("точка ({0},{1}) находится в фигуре", x, y);
- }
- }
- Console.WriteLine("Если хотите продолжить введите 1");
- exit = int.Parse(Console.ReadLine());
- }
- }
- static bool IsDigit(string number)
- {
- if (!((number[0] >= '0' && number[0] <= '9') || number[0] == '-'))
- {
- return false;
- }
- for (int i = 1; i < number.Length; i++)
- {
- if (!(number[i] >= '0' && number[i] <= '9'))
- {
- return false;
- }
- }
- return true;
- }
- static void check(string x1)
- {
- while (IsDigit(x1) != true)
- {
- Console.WriteLine("Некорректные данные, если хотите выйти введите 2, иначе введите другой символ");
- string exit2 = Console.ReadLine();
- if (exit2.Equals("2"))
- {
- Environment.Exit(0);
- }
- else
- {
- Console.Write("Введите x: ");
- x1 = Console.ReadLine();
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment