Advertisement
nevenailievaa

2201682020-Domashno1

Oct 8th, 2022
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.50 KB | None | 0 0
  1. namespace HomeWork1
  2. {
  3.     using System;
  4.     using System.Linq;
  5.  
  6.     class Task_1
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             bool isExitLoop = false;
  11.             int n = 0;
  12.  
  13.             while (!isExitLoop)
  14.             {
  15.                 n = int.Parse(Console.ReadLine());
  16.  
  17.                 if (n >= 13 && n <= 25)
  18.                 {
  19.                     isExitLoop = true;
  20.                 }
  21.             }
  22.  
  23.             int[] arr = CreateArray(n);
  24.  
  25.             int[] sortedArray = arr.OrderByDescending(x => x).ToArray();
  26.  
  27.             Console.WriteLine(String.Join(" ", sortedArray));
  28.         }
  29.  
  30.         {
  31.             int[] result = new int[n];
  32.  
  33.             for (int i = 0; i < result.Length; i++)
  34.             {
  35.                 result[i] = int.Parse(Console.ReadLine());
  36.             }
  37.  
  38.             return result;
  39.         }
  40.  
  41.         {
  42.             int max = int.MinValue;
  43.  
  44.             for (int i = 0; i < arr.Length; i++)
  45.             {
  46.                 if (arr[i] > max)
  47.                 {
  48.                     max = arr[i];
  49.                 }
  50.             }
  51.  
  52.             return max;
  53.         }
  54.         {
  55.             for (int i = 0; i < arr.Length; i++)
  56.             {
  57.                 if (arr[i] > x)
  58.                 {
  59.                     Console.WriteLine(arr[i]);
  60.                 }
  61.             }
  62.         }
  63.  
  64.         static void Comb()
  65.         {
  66.             int n = int.Parse(Console.ReadLine());
  67.             int k = int.Parse(Console.ReadLine());
  68.  
  69.             int[] arr = new int[n];
  70.             int[] combinations = new int[k];
  71.  
  72.             for (int i = 0; i < n; i++)
  73.             {
  74.                 arr[i] = i + 1;
  75.             }
  76.  
  77.             Combinations(0, 0, arr, combinations);
  78.  
  79.             static void Combinations(int index, int elementsStartIndex, int[] elements, int[] combinations)
  80.             {
  81.                 if (index >= combinations.Length)
  82.                 {
  83.  
  84.                     foreach (int item in combinations)
  85.                     {
  86.                         Console.Write($"{item} ");
  87.                     }
  88.  
  89.                     Console.WriteLine();
  90.                 }
  91.                 else
  92.                 {
  93.                     for (int i = elementsStartIndex; i < elements.Length; i++)
  94.                     {
  95.                         combinations[index] = elements[i];
  96.                         Combinations(index + 1, i + 1, elements, combinations);
  97.                     }
  98.                 }
  99.             }
  100.         }
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement