Advertisement
wingman007

KrushkovTasks

Nov 27th, 2021 (edited)
771
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.58 KB | None | 0 0
  1. // ---------------------------------- Test 1 -2 II --------------------------------------
  2. //using System;
  3.  
  4. //namespace MyPrograme
  5. //{
  6. //    public class Program {
  7. //        static void Main(string[] args)
  8. //        {
  9.  
  10.             double b = 2.3, y = 5.6, result;
  11.  
  12.             result = (b + Math.Pow(Math.Sin(Math.Pow(Math.PI, 4)), 2)) / (Math.Pow(Math.Cos(6), 1.0 / 5) + Math.Abs(1 / Math.Tan(y)));
  13.  
  14.             Console.WriteLine(result);
  15.  
  16. //        }
  17. //    }
  18. //}
  19.  
  20.  
  21. // ------------------------- Test 1 - 1 I) -------------------------
  22.  
  23. double x = 1.1, y = 3.4, z = 4.5, result;
  24. result = (Math.Pow(x, 7) * y * z - 3.3 * Math.Abs(x + Math.Pow(y, 1/4))) / Math.Pow(10, 7) + Math.Sqrt(Math.Log(4, Math.E));
  25. Console.WriteLine(result);
  26.  
  27. --------------------------- 380 --------------------------
  28.  
  29. Console.Write("Please, enter k = ");
  30. int k = int.Parse(Console.ReadLine());
  31. int sum = 0;
  32. int num;
  33. do
  34. {
  35.     Console.Write("Please, enter an int number (0 for exit): ");
  36.     num = int.Parse(Console.ReadLine());
  37.     if (num % 2 == 1) sum += num;
  38. } while (num != 0);
  39.  
  40. Console.Write(sum);
  41.  
  42. // ---------------------------- 404 -----------
  43.  
  44. using System;
  45.  
  46. namespace MyNamespace
  47. {
  48.     class Program
  49.     {
  50.         static void Main()
  51.         {
  52.            
  53.             int k;
  54.             do
  55.             {
  56.                 Console.Write("Please, eneter the size of the array [2;50]: ");
  57.                 k = int.Parse(Console.ReadLine());
  58.             } while (k < 2 || k > 50);
  59.  
  60.             int[] array = new int[k];
  61.  
  62.             for (int i = 0; i < array.Length; i++)
  63.             {
  64.                 Console.Write("Please eneter element array[{0}] = ", i);
  65.                 array[i] = int.Parse(Console.ReadLine());
  66.             }
  67.  
  68.             Console.WriteLine("The sum of the array elements > 40 is {0}", Sum(array, 40));
  69.         }
  70.  
  71.         static int Sum(int[] array, int k)
  72.         {
  73.             int sum = 0;
  74.  
  75.             for (int i = 0; i < array.Length; i++)
  76.             {
  77.                 if (array[i] > k)
  78.                 {
  79.                     sum += array[i];
  80.                 }
  81.             }
  82.  
  83.             return sum;
  84.         }
  85.     }
  86. }
  87.  
  88. // ------------------------------ Task 83 ----------------------------
  89. int max = 100;
  90. for (int i = 1, j = 100; i < 51; i += 2, j -= 2)
  91. {
  92.     Console.Write("{0}, {1}, {2}, {3}, ", i, i + 1, j, j - 1);
  93. }
  94.  
  95. // -------------------- 4 g ----------------------------
  96. double x = 1.2, y = 3.4, z = 5.6, a = 6.7, b = 2.3, result;
  97. result = Math.Pow((y + 6 * a - 2) / (3 * (x + 6)), 6) - (z / (z + 7 * b));
  98. Console.WriteLine(result);
  99.  
  100. // ------------ 122 g ----------------------
  101.  
  102. using System;
  103.  
  104. namespace MyNamespace
  105. {
  106.     class Program
  107.     {
  108.         static void Main()
  109.         {
  110.  
  111.             double x = 1.2, y = 1;
  112.             for (int n = 0; n < 5; n++)
  113.             {
  114.                 y += (Math.Pow(-1, n) * Math.Pow(x, 2 * n)) / Factorial(2 * n);
  115.             }
  116.  
  117.             y = 1 - y;
  118.  
  119.             Console.WriteLine(y);
  120.         }
  121.  
  122.         static int Factorial(int n)
  123.         {
  124.             int factorial = 1;
  125.  
  126.             for (int i = 1; i <= n; i++)
  127.             {
  128.                 factorial += i;
  129.             }
  130.  
  131.             return factorial;
  132.         }
  133.     }
  134. }
  135.  
  136. // -------------------------  36 j --------------------------
  137. int x = -2, y = -3, z = -4;
  138. Console.WriteLine( (x < 0 && y < 0 && z < 0)? true : false);
  139.  
  140. // ------------------------ Task 12 --------------------------
  141. Console.Write("Please, eneter a number with 7 digits: ");
  142. int i = int.Parse(Console.ReadLine());
  143. Console.WriteLine((i / 1000) % 10);
  144.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement