Как или что написать или дописать что бы программа заработала. - C#
Формулировка задачи:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(" + -----------------+-----------------+");
Console.WriteLine(" | y | x +");
Console.WriteLine(" + -----------------+-----------------+");
double y = 0, a = 1.6, x = 0.2, b = 1.24, n = 6, e = 2.718;
while (x < 1.5)
{
y = (Math.Pow(b + (Math.Asin(a * x)), 2)) / (Math.Pow(e, -b * x));
if (x == 0.2)
Console.WriteLine("| " + Math.Round(y, 0,2 ) + " | " + Math.Round(x, 0,2) + " |");
if (x != 0.2)
Console.WriteLine("| " + Math.Round(y, 0,2) + " | " + Math.Round(x, 0,2) + " |");
Console.WriteLine("+-----------------+-----------------+");
x += 0.2;
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Console.WriteLine("+-----------------+-----------------+");
Console.WriteLine("| y | x +");
Console.WriteLine("+-----------------+-----------------+");
int i = 0;
double[] X = { 0.2, 1.45, 0.36, 0.92, 0.75, 0.44 };
while (n > i)
{
y = (Math.Pow(b + (Math.Asin(a * X[i])), 2)) / (Math.Pow(e, -b * X[i]));
if (i == 0)
Console.WriteLine("| " + Math.Round(y, 0,2) + " | " + Math.Round(X[i], 0,2) + " |");
if (i == 1)
Console.WriteLine("| " + Math.Round(y, 0,2) + " | " + Math.Round(X[i], 0,2) + " |");
if (i != 0 && i != 1)
Console.WriteLine("| " + Math.Round(y, 0,2) + " | " + Math.Round(X[i], 0,2) + " |");
Console.WriteLine("+-----------------+-----------------+");
i++;
}
Console.ReadLine();
}
}
}Решение задачи: «Как или что написать или дописать что бы программа заработала.»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("+---------------+---------------+");
Console.WriteLine("|\ty\t|\tx\t|");
Console.WriteLine("+---------------+---------------+");
double y = 0, a = 1.6, x = 0.2, b = 1.24, n = 6, e = 2.718;
while (x < 1.5)
{
y = (Math.Pow(b + (Math.Asin(a * x)), 2)) / (Math.Pow(e, -b * x));
if (x == 0.2)
Console.WriteLine("|\t" + Math.Round(y, 2 ) + "\t|\t" + Math.Round(x, 2) + "\t|");
if (x != 0.2)
Console.WriteLine("|\t" + Math.Round(y, 2) + "\t|\t" + Math.Round(x, 2) + "\t|");
Console.WriteLine("+---------------+---------------+");
x += 0.2;
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Console.WriteLine("+---------------+---------------+");
Console.WriteLine("|\ty\t|\tx\t|");
Console.WriteLine("+---------------+---------------+");
int i = 0;
double[] X = { 0.2, 1.45, 0.36, 0.92, 0.75, 0.44 };
while (n > i)
{
y = (Math.Pow(b + (Math.Asin(a * X[i])), 2)) / (Math.Pow(e, -b * X[i]));
if (i == 0)
Console.WriteLine("|\t" + Math.Round(y, 2) + "\t|\t" + Math.Round(X[i], 2) + "\t|");
if (i == 1)
Console.WriteLine("|\t" + Math.Round(y, 2) + "\t|\t" + Math.Round(X[i], 2) + "\t|");
if (i != 0 && i != 1)
Console.WriteLine("|\t" + Math.Round(y, 2) + "\t|\t" + Math.Round(X[i], 2) + "\t|");
Console.WriteLine("+---------------+---------------+");
i++;
}
Console.ReadLine();
}
}
}