Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Numerics;
- namespace Methods_Bank
- {
- class Program
- {
- static void Main(string[] args)
- {
- PrimePrint();
- }
- private static void Cub()
- {
- //Cube properties
- var side = double.Parse(Console.ReadLine());
- var typeCalc = Console.ReadLine();
- //
- var result = 0.0;
- if (typeCalc == "face")
- {
- result = FaceCub(side);
- }
- if (typeCalc == "space")
- {
- result = spaceCub(side);
- }
- if (typeCalc == "volume")
- {
- result = VolumeCub(side);
- }
- if (typeCalc == "area")
- {
- result = SurfaceCub(side);
- }
- Console.WriteLine($"{result:F2}");
- }
- public static double FaceCub(double n)
- {
- var result = Math.Sqrt(2 * Math.Pow(n, 2));
- return result;
- }
- public static double spaceCub(double n)
- {
- var result = Math.Sqrt(3 * Math.Pow(n, 2));
- return result;
- }
- public static double VolumeCub(double n)
- {
- var result = (Math.Pow(n, 3));
- return result;
- }
- public static double SurfaceCub(double n)
- {
- var result = 6 * (Math.Pow(n, 2));
- return result;
- }
- private static void LongLine()
- {
- var x1 = double.Parse(Console.ReadLine());
- var y1 = double.Parse(Console.ReadLine());
- var x2 = double.Parse(Console.ReadLine());
- var y2 = double.Parse(Console.ReadLine());
- var x3 = double.Parse(Console.ReadLine());
- var y3 = double.Parse(Console.ReadLine());
- var x4 = double.Parse(Console.ReadLine());
- var y4 = double.Parse(Console.ReadLine());
- //
- var len1 = LineLenght(x1, y1, x2, y2);
- var len2 = LineLenght(x3, y3, x4, y4);
- if (len1 > len2)
- {
- var closer = CloserOrNot(x1, y1, x2, y2);
- if (closer)
- {
- Console.WriteLine($"({x1}, {y1})({x2}, {y2})");
- }
- else
- {
- Console.WriteLine($"({x2}, {y2})({x1}, {y1})");
- }
- }
- else
- {
- var closer = CloserOrNot(x3, y3, x4, y4);
- if (closer)
- {
- Console.WriteLine($"({x3}, {y3})({x4}, {y4})");
- }
- else
- {
- Console.WriteLine($"({x4}, {y4})({x3}, {y3})");
- }
- }
- }
- public static bool CloserOrNot(double x1, double y1, double x2, double y2)
- {
- var a = Math.Sqrt(x1 * x1 + y1 * y1);
- var b = Math.Sqrt(x2 * x2 + y2 * y2);
- bool check = true;
- if (a < b)
- {
- check = true;
- }
- else
- {
- check = false;
- }
- return check;
- }
- public static double LineLenght(double x1, double y1, double x2, double y2)
- {
- var lenght = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
- return lenght;
- }
- private static void CenterPoint1_1(double x1, double y1, double x2, double y2)
- {
- var c = Math.Sqrt(x1 * x1 + y1 * y1);
- Math.Abs(c);
- var nC = Math.Sqrt(x2 * x2 + y2 * y2);
- Math.Abs(nC);
- //
- var x = 0.0;
- var y = 0.0;
- if (c < nC)
- {
- x = x1;
- y = y1;
- }
- if (c > nC)
- {
- x = x2;
- y = y2;
- }
- else
- {
- x = x1;
- y = y1;
- }
- Console.WriteLine($"({x}, {y})");
- }
- private static void CenterPoint(double x1, double y1, double x2, double y2)
- {
- bool first = (x1 < x2) && (y1 < y2);
- bool second = (x1 > x2) && (y1 > y2);
- double x = 0.0;
- double y = 0.0;
- if (first)
- {
- x = x1;
- y = y1;
- }
- if (second)
- {
- y = y2;
- x = x2;
- }
- else
- {
- x = x1;
- y = y1;
- }
- Console.WriteLine($"({x}, {y})");
- }
- private static void PrimePrint()
- {
- var n = int.Parse(Console.ReadLine());
- var n1 = int.Parse(Console.ReadLine());
- //
- List<int> isP = FindPrimesInRange(n, n1);
- for (int i = 0; i < isP.Count; i++)
- {
- if (isP[i] != isP[isP.Count - 1])
- {
- Console.Write(isP[i] + ", ");
- }
- else
- {
- Console.WriteLine(isP[i]);
- }
- }
- }
- public static List<int> FindPrimesInRange(int startNum, int endNum)
- {
- List<int> nn = new List<int>();
- var isPP = false;
- for (int i = startNum; i <= endNum; i++)
- {
- isPP = Prime(i);
- if (isPP)
- {
- nn.Add(i);
- }
- }
- return nn;
- }
- public static bool Prime(long n)
- {
- if (n == 0 || n == 1)
- {
- return false;
- }
- for (int i = 2; i <= Math.Sqrt(n); i++)
- {
- if (n % i == 0)
- {
- return false;
- }
- }
- return true;
- }
- private static void Fibb()
- {
- var num = long.Parse(Console.ReadLine());
- var n = Fib(num);
- Console.WriteLine(n);
- }
- public static long Fib(long n)
- {
- if (n == 0)
- {
- return 1;
- }
- if (n == 1)
- {
- return 1;
- }
- if (n == 2)
- {
- return 2;
- }
- long fi = Fib(n - 1) + Fib(n - 2);
- return fi;
- }
- private static void ReversedData()
- {
- var num = Console.ReadLine();
- var newW = Reversed((num));
- double rever = Convert.ToDouble(newW);
- Console.WriteLine(rever);
- }
- public static string Reversed(string str)
- {
- string newnum = "";
- for (int i = str.Length - 1; i >= 0; i--)
- {
- newnum += str[i];
- }
- return newnum;
- }
- public static void EnglishName(long n)
- {
- if (n < 0)
- {
- n *= (-1);
- }
- long lastDigit = n % 10;
- var str = "";
- switch (lastDigit)
- {
- case 0: str = "zero"; break;
- case 1: str = "one"; break;
- case 2: str = "two"; break;
- case 3: str = "three"; break;
- case 4: str = "four"; break;
- case 5: str = "five"; break;
- case 6: str = "six"; break;
- case 7: str = "seven"; break;
- case 8: str = "eight"; break;
- case 9: str = "nine"; break;
- }
- Console.WriteLine(str);
- }
- private static void GetMaxx()
- {
- var a = int.Parse(Console.ReadLine());
- var b = int.Parse(Console.ReadLine());
- var c = int.Parse(Console.ReadLine());
- //
- var max = 0;
- if (GetMax(a, b) > c)
- {
- max = GetMax(a, b);
- }
- else
- {
- max = c;
- }
- Console.WriteLine(max);
- }
- public static int GetMax(int a, int b)
- {
- var greatest = 0;
- if (a > b)
- {
- greatest = a;
- }
- else
- {
- greatest = b;
- }
- return greatest;
- }
- private static void Greeting()
- {
- //Name => Greeting
- var input = Console.ReadLine();
- string prt = Hello(input);
- Console.WriteLine(prt);
- }
- public static string Hello(string h)
- {
- var hello = $"Hello, {h}!";
- return hello;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement