Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CourseApp.Tests/DemoTest.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
namespace CourseApp.Tests
{
using CourceApp;
using Xunit;

public class DemoTest
{
[Fact]
public void Test1()
{
Assert.True(true);
var taskAMass = Task.TaskA(1.28, 3.28, 0.4);
Assert.Equal(6, taskAMass.Count);
}
}
}
95 changes: 95 additions & 0 deletions CourseApp/Codewars.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
namespace CourseApp
{
using System.Linq;

public class Codewars
{
public static string EvenOrOdd(int number) // чётное или нечётное
{
return number % 2 == 0 ? "Even" : "Odd";
}

public static int CountSheeps(bool[] sheeps) // овцы
{
int count = 0;
foreach (bool sheep in sheeps)
{
if (sheep == true)
{
count++;
}
}

return count;
}

public static int[] MonkeyCount(int n) // почситать обезьян
{
int elem = 1;
int[] mass = new int[n];
for (byte index = 0; index < mass.Length; index++)
{
if (elem <= n)
{
mass[index] = elem++;
}
}

return mass;
}

public static int Paperwork(int n, int m) // посчитать количество страниц
{
int result = 0;
if (n > 0 && m > 0)
{
result = m * n;
}

return result;
}

public static bool Hero(int bullets, int dragons) => bullets / dragons >= 2; // драконы

public static int[] FindAll(int[] a, int n) => Enumerable.Range(0, a.Length).Where(i => a[i] == n).ToArray(); // индексы вхожддений

public static int SumOfMinimums(int[,] numbers) // сумма минимумов
{
var result = 0;
for (int i = 0; i < numbers.GetLength(0); i++)
{
var min = numbers[i, 0];
for (int j = 1; j < numbers.GetLength(1); j++)
{
if (numbers[i, j] < min)
{
min = numbers[i, j];
}
}

result += min;
}

return result;
}

public static string PolishToEnglish(string sentence) // перевод польский на русский
{
char[] result = sentence.ToCharArray();
char[] polish = new char[] { 'ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż' };
char[] english = new char[] { 'a', 'c', 'e', 'l', 'n', 'o', 's', 'z', 'z' };
for (byte i = 0; i < result.Length; i++)
{
for (byte j = 0; j < polish.Length; j++)
{
if (result[i] == polish[j])
{
result[i] = english[j];
}
}
}

return new string(result);
}
}
}
36 changes: 13 additions & 23 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
namespace Informatics_2022
namespace CourceApp
{
using System;
using CourseApp;

internal class Program : Task
internal class Program
{
private static void Main()
{
Console.Write("Введите, ответ на какую задачу хотите получить (A или B):");
string zadacha = Console.ReadLine();
switch (zadacha)
/* Console.WriteLine("A:");
foreach (double elem in Task.TaskA(1.28, 3.28, 0.4))
{
case "A":
for (double x = 1.28; x <= 3.28; x += 0.4)
{
Task.Alg(x);
}

Console.ReadLine();
break;
Console.WriteLine(elem);
}

case "B":
double[] x_massB = new double[] { 1.1f, 2.4f, 3.6f, 1.7f, 3.9f };
foreach (double x in x_massB)
{
Task.Alg(x);
}
Console.WriteLine("B:");
foreach (double elem in Task.TaskB(new double[] { 1.1, 2.4, 3.6, 1.7, 3.9 }))
{
Console.WriteLine(elem);
}*/

Console.ReadLine();
break;
}
}
Console.Write(Codewars.PolishToEnglish("Jędrzej Błądziński") + "Jędrzej Błądziński".Length);
}
}
}
58 changes: 53 additions & 5 deletions CourseApp/Task.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,64 @@
namespace CourseApp
namespace CourceApp
{
using System;
using System.Collections.Generic;

public class Task
{
public static void Alg(double x)
public static double[] GetZnamen
{
double b_cube = Math.Pow(2.5f, 3);
get
{
return GetZnamen;
}

private set
{
GetZnamen[0] = Znamen(1.1);
GetZnamen[1] = Znamen(2.4);
GetZnamen[2] = Znamen(3.6);
GetZnamen[3] = Znamen(1.7);
GetZnamen[4] = Znamen(3.9);
}
}

public static double Alg(double x, double b = 2.5)
{
double b_cube = Math.Pow(b, 3);
double x_cube = Math.Pow(x, 3);
double verx = Math.Pow(Math.Sin(b_cube + x_cube), 2);
double niz = 1 + Math.Pow(x_cube + b_cube, 1 / 3);
Console.WriteLine(verx / niz);
double niz = Znamen(x);
return verx / niz;
}

public static List<double> TaskA(double startX, double finX, double deltaX)
{
List<double> doubles = new List<double>();
for (double x = startX; x <= finX; x += deltaX)
{
doubles.Add(Alg(x));
}

return doubles;
}

public static List<double> TaskB(double[] mass)
{
List<double> doubles = new List<double>();
foreach (double x in mass)
{
doubles.Add(Alg(x));
}

return doubles;
}

private static double Znamen(double x, double b = 2.5)
{
double bCube = Math.Pow(b, 3);
double xCube = Math.Pow(x, 3);
var znamen = Math.Pow(bCube / xCube, 1 / 3);
return znamen;
}
}
}