Last active
May 25, 2019 09:26
-
-
Save alldevic/5521435582426550d6af183c4efed8e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Task1 | |
{ | |
internal class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
double R, x, y; | |
try | |
{ | |
Console.WriteLine("Введите парраметр значения R"); | |
R = Convert.ToDouble(Console.ReadLine()); | |
Console.WriteLine("Введите парраметр значения x"); | |
x = Convert.ToDouble(Console.ReadLine()); | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine("Введены некорректные данные"); | |
return; | |
} | |
if (x <= -3) | |
{ | |
y = x + 3; | |
} | |
else if (x <= 0) | |
{ | |
y = Math.Sqrt(Math.Pow(R, 2) - Math.Pow(x, 2)); | |
} | |
else if (x <= 6) | |
{ | |
y = 3 - x / 2; | |
} | |
else | |
{ | |
y = x - 6; | |
} | |
Console.WriteLine("Значение функции:" + y); | |
Console.ReadKey(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Task2 | |
{ | |
internal class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
double R1, R2, x; | |
bool flag = false; | |
try | |
{ | |
Console.WriteLine("Введите парраметр значения R1"); | |
R1 = Convert.ToDouble(Console.ReadLine()); | |
Console.WriteLine("Введите парраметр значения R2"); | |
R2 = Convert.ToDouble(Console.ReadLine()); | |
Console.WriteLine("Введите парраметр значения x"); | |
x = Convert.ToDouble(Console.ReadLine()); | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine("Введены некорректные данные"); | |
return; | |
} | |
if (R2 < R1) | |
{ | |
Console.WriteLine("Введеный R2 < R1 "); | |
} | |
if (x < -Math.Pow(R1, 2) && x > Math.Pow(R2, 2)) | |
{ | |
Console.WriteLine("Введенный x не лежит на отрезке [" + | |
(-Math.Pow(R1, 2) + ", " + Math.Pow(R2, 2) + "]")); | |
return; | |
} | |
if ((x < 0) && (x > -Math.Pow(R1, 2))) | |
{ | |
flag = true; | |
} | |
if (x >= Math.Pow(R1, 2) && x <= Math.Pow(R2, 2)) | |
{ | |
flag = true; | |
} | |
Console.WriteLine(flag | |
? "Есть попадание в мишень" | |
: "Попадания в мишень нет" | |
); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment