ranee

массив двумерный

Sep 6th, 2022 (edited)
709
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Task_24_Repeat_In_Array
  8. {
  9.     internal class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] array = new int []{ 45, 14, 22, 214, 5, 33, 22, 63, 79, 10, 144, 12 };
  14.             int temp = 0;
  15.  
  16.             foreach (var item in array)
  17.             {
  18.                 Console.Write($"{item} ");
  19.             }
  20.            
  21.             for (int i = 0; i < array.Length; i++)
  22.                 for (int j = i + 1; j < array.Length; j++)
  23.                     if (array[i] > array[j])
  24.                     {
  25.                         temp = array[j];
  26.                         array[j] = array[i];
  27.                         array[i] = temp;
  28.                     }
  29.             Console.WriteLine();
  30.            
  31.             foreach (var item in array)
  32.             {
  33.                 Console.Write($"{item} ");
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment