Advertisement
Dr_Max_Experience

New Task 9

Mar 19th, 2022 (edited)
903
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 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 HW
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] array = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
  14.             int temporaryNumber;
  15.  
  16.             int valueShiftArray = Convert.ToInt32(Console.ReadLine());
  17.  
  18.             ShowArray(array);
  19.  
  20.             for (int j = valueShiftArray; j > 0; j--)
  21.             {
  22.                 for (int i = 0; i < array.Length - 1; i++)
  23.                 {
  24.                     temporaryNumber = array[i];
  25.                     array[i] = array[i + 1];
  26.                     array[i + 1] = temporaryNumber;
  27.                 }
  28.             }
  29.  
  30.             ShowArray(array);
  31.         }
  32.  
  33.         static void ShowArray(int[] array)
  34.         {
  35.             foreach (var number in array)
  36.             {
  37.                 Console.Write(number + " ");
  38.             }
  39.  
  40.             Console.WriteLine();
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement