Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace ConsoleApp2
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Tri();
  11. Chetire();
  12.  
  13. }
  14.  
  15. public static void Tri()
  16. {
  17. Console.WriteLine("введите длинну массива");
  18. try
  19. {
  20.  
  21.  
  22. int len = int.Parse(Console.ReadLine());
  23. int n = 0;
  24. int[] arr = new int[len];
  25. double[] arr_2 = new double[len];
  26.  
  27. Console.WriteLine("введите элементы маасива");
  28.  
  29. while (n < arr.Length)
  30. {
  31. int elem = int.Parse(Console.ReadLine());
  32. arr[n] = elem;
  33. n++;
  34.  
  35. }
  36. int arr_min = Array.LastIndexOf(arr, arr.Min());
  37.  
  38. int[] arr_dop_2 = arr.Skip(arr_min).ToArray();
  39.  
  40. int dop = 0;
  41. foreach (int i in arr_dop_2)
  42. {
  43. dop += i;
  44. }
  45. Console.WriteLine($"Твоя сумма - {dop}");
  46. }
  47. catch
  48. {
  49. Console.WriteLine("У вас ошибка");
  50. }
  51. }
  52.  
  53. public static void Chetire()
  54. {
  55. Console.WriteLine("введите длинну массива");
  56. try
  57. {
  58.  
  59.  
  60. int len = int.Parse(Console.ReadLine());
  61. int n = 0;
  62. double[] arr = new double[len];
  63. double[] arr_2 = new double[len];
  64.  
  65. Console.WriteLine("введите элементы маасива");
  66.  
  67. while (n < arr.Length)
  68. {
  69. double elem = double.Parse(Console.ReadLine());
  70. arr[n] = elem;
  71. n++;
  72.  
  73. }
  74. n = 0;
  75. foreach (int i in arr)
  76. {
  77. if (i % 2 == 0)
  78. {
  79. arr_2[n] = i;
  80. n++;
  81. }
  82. }
  83. foreach (int i in arr_2)
  84. {
  85. if (i != 0)
  86. {
  87. Console.WriteLine($"Твой массив - {i}");
  88. }
  89. }
  90.  
  91. }
  92. catch
  93. {
  94. Console.WriteLine("У вас ошибка");
  95. }
  96. }
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement