Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Numerics;
- using System.Text;
- namespace ConsoleApp3a
- {
- class Program
- {
- static void Main(string[] args)
- {
- //BigInteger bInt
- Console.OutputEncoding = Encoding.UTF8;
- Console.WriteLine("Hello World!");
- Console.WriteLine(SayTheDigit(3));
- Console.WriteLine(IsPointIn(1.2, 2.3, 10));
- // 0!= 1;
- // n! = (n-1)! *n;
- // 10
- int factorial = 0;
- for (int i = 0; i < 10; i++)
- {
- if (i == 0)
- {
- factorial = 1;
- }
- else
- {
- factorial *= i;
- }
- }
- Console.WriteLine("10! = {0}", factorial);
- Console.WriteLine(Factorial(10));
- // 1,1,2,3,5,8,13,21,34
- Console.WriteLine(Fibonacci(40));
- //for (int i = 0; i < 5; i++)
- //{
- // Console.Write("{0}, ", Fibonacci(i));
- //}
- Console.Write("Please enter a = ");
- double a = double.Parse(Console.ReadLine());
- Console.WriteLine();
- Console.Write("Please enter b = ");
- double b = double.Parse(Console.ReadLine());
- Console.WriteLine();
- Console.Write("Please enter c = ");
- double c = double.Parse(Console.ReadLine());
- Console.WriteLine();
- Console.WriteLine("Is existing? - {0}.", CheckTriangleExists(a,b,c));
- if (CheckTriangleExists(a, b, c)) {
- Console.WriteLine("The surface is: {0}", CalculateSurface(a, b, c));
- }
- }
- static double InputSite(string nameVariable) {
- Console.Write($"Please enter {nameVariable} = ");
- return double.Parse(Console.ReadLine());
- // Console.WriteLine();
- }
- static bool CheckTriangleExists(double a, double b, double c)
- {
- bool isExists = false;
- if (a < b + c && b < c + a && c < b + a) isExists = true;
- // return (a < b + c && b < c + a && c < b + a);
- return isExists;
- }
- static double CalculateSurface(double a, double b, double c) {
- double perimeter = a + b + c;
- return Math.Sqrt(perimeter * (perimeter - a) * (perimeter - b) * (perimeter - c));
- }
- static int Factorial(int n)
- {
- if (n == 0) return 1; // 0!= 1;
- return Factorial(n - 1) * n; // n! = (n-1)! *n;
- }
- static int Fibonacci(int number)
- {
- if (number == 1 || number == 2) return 1;
- return Fibonacci(number - 1) + Fibonacci(number - 2);
- }
- static bool IsPointIn(double x, double y, double r)
- {
- bool isIn = false;
- double d = Math.Sqrt(Math.Pow((x - 1), 2) + Math.Pow((y - 0), 2));
- isIn = d > r;
- return isIn;
- }
- static string SayTheDigit(int digit) {
- string digitName = "";
- switch (digit)
- {
- case 1:
- digitName = "едно";
- break;
- case 2:
- digitName = "две";
- break;
- case 3:
- digitName = "три";
- break;
- case 4:
- digitName = "четири";
- break;
- case 5:
- digitName = "пет";
- break;
- case 6:
- digitName = "шест";
- break;
- default:
- break;
- }
- return digitName;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement