У меня есть метод Formula(int[] arr), которому необходимо передать в параметры возвращаемый массив из метода Input(), каким образом это можно реализовать?
using System;
namespace Laba10
{
class Program
{
static void Main()
{
while (true)
{
Console.Write("Какую программу запустим (1 - шаг и промежуток, 2 - вывод, 3 - сортировка №1, 4 - сортировка №2, 5 - сортировка №3, 6 - статистика, 7 - выход)?: ");
char answer = char.Parse(Console.ReadLine());
switch (answer)
{
case '1':
Program.Input();
break;
case '2':
Program.Formula(Input());
break;
default:
break;
}
break;
}
}
static int[] Input()
{
Console.Write("Введите точку начала: ");
int begin = int.Parse(Console.ReadLine());
Console.Write("Укажите шаг: ");
int step = int.Parse(Console.ReadLine());
Console.Write("Введите интервал: ");
int interval = int.Parse(Console.ReadLine());
int[] arr = new int[] { begin, step, interval };
Program.Main();
return arr;
}
static void Formula(int[] arr)
{
Console.Write("Введите значение а: ");
double a = double.Parse(Console.ReadLine());
Console.Write("Введите значение b: ");
double b = double.Parse(Console.ReadLine());
double y = 0, x;
if (arr[0] < arr[2] && arr[1] > 0)
{
while (arr[0] <= arr[2])
{
x = arr[0];
if (Math.Sqrt(x - b) != 0)
{
y = (a + b * x * Math.Tan(x - b)) / (Math.Sqrt(x - b));
Console.Write($"{x}\t {Math.Round(y, 2)}");
}
arr[0] += arr[1];
}
}
else if (arr[0] > arr[2] && arr[1] > 0)
{
while (arr[0] >= arr[2])
{
x = arr[0];
if (Math.Sqrt(x - b) != 0)
{
y = (a + b * x * Math.Tan(x - b)) / (Math.Sqrt(x - b));
Console.Write($"{x}\t {Math.Round(y, 2)}");
}
arr[0] -= arr[1];
}
}
else
{
Console.WriteLine("Введены некорректные данные");
}
Program.Main();
}
}
}
case '2':
как раз это и делаете