Advertisement
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_1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Title = "Дана точка на плоскости с координатами (х, у). Узнать где она лежит.";
- const int r = 15;
- Console.WriteLine("Система уравнений: \n y>|x|, \n x^2+y^2=r^2; , где r = {0}", r);
- 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();
- x1 = x1.Trim();
- check(y1);
- double y = double.Parse(y1);
- if (y < Math.Abs(x) || Math.Pow(x, 2) + Math.Pow(y, 2) > Math.Pow(r, 2))
- {
- Console.WriteLine("точка ({0},{1}) находится вне фигуры",x,y);
- }
- else
- {
- if (y == Math.Abs(x) || Math.Pow(x, 2) + Math.Pow(y, 2) == Math.Pow(r, 2))
- {
- 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();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement