Графики. Найти 'y' в зависимости от 'x' - C#
Формулировка задачи:
Составить программу вычисляющую 'y' в зависимости от изменения 'x'. Половина программы написана, а вот то, что идет после окружности не знаю формул. Help ME!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _12_графики
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("{0,53}", "Практическое задание №12. Вариант 7");
Console.WriteLine();
double x=0,
y=0;
Console.WriteLine("Введите x");
x = Convert.ToDouble(Console.ReadLine());
if ((x >= -7) && (x < -3))
{
y = 3;
}
if ((x >= -3) && (x < 3))
{
double r = 3;
y = -Math.Sqrt(Math.Pow(x, 2) + Math.Pow(r, 2)) + 3;
}
if ((x >= 3) && (x < 6))
{
//здесь что-то;
}
if ((x>=6) && (x<11)) {
//здесь что-то;
}
}
}
}Решение задачи: «Графики. Найти 'y' в зависимости от 'x'»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace formulae_chart
{
class Program
{
private static double yD(double x)
{
if (x < -3) return 3;
else if (x >= -3 && x <= 3) return -Math.Sqrt(9 - x * x) + 3;
else if (x > 3 && x < 6) return -2*x + 9;
else return x - 9;
}
static void Main(string[] args)
{
Console.WriteLine(yD(-4));
Console.WriteLine(yD(-3));
Console.WriteLine(yD(0));
Console.WriteLine(yD(3));
Console.WriteLine(yD(4.5));
Console.WriteLine(yD(6));
Console.WriteLine(yD(9));
Console.ReadLine();
}
}
}