Отобразить зеркально одномерный массив относительно середины - C#

Узнай цену своей работы

Формулировка задачи:

Отобразить зеркально одномерный массив относительно середины.Срочно нужно! Заранее спасибо.

Решение задачи: «Отобразить зеркально одномерный массив относительно середины»

textual
Листинг программы
  1. using System;
  2. public class SamplesArray  {
  3.  
  4.    public static void Main()  {
  5.  
  6.       // Creates and initializes a new Array.
  7.       Array myArray=Array.CreateInstance( typeof(String), 9 );
  8.       myArray.SetValue( "The", 0 );
  9.       myArray.SetValue( "quick", 1 );
  10.       myArray.SetValue( "brown", 2 );
  11.       myArray.SetValue( "fox", 3 );
  12.       myArray.SetValue( "jumps", 4 );
  13.       myArray.SetValue( "over", 5 );
  14.       myArray.SetValue( "the", 6 );
  15.       myArray.SetValue( "lazy", 7 );
  16.       myArray.SetValue( "dog", 8 );
  17.  
  18.       // Displays the values of the Array.
  19.       Console.WriteLine( "The Array initially contains the following values:" );
  20.       PrintIndexAndValues( myArray );
  21.  
  22.       // Reverses the sort of the values of the Array.
  23.       Array.Reverse( myArray );
  24.  
  25.       // Displays the values of the Array.
  26.       Console.WriteLine( "After reversing:" );
  27.       PrintIndexAndValues( myArray );
  28.    }
  29.  
  30.  
  31.    public static void PrintIndexAndValues( Array myArray )  {
  32.       for ( int i = myArray.GetLowerBound(0); i <= myArray.GetUpperBound(0); i++ )
  33.          Console.WriteLine( "\t[{0}]:\t{1}", i, myArray.GetValue( i ) );
  34.    }
  35. }
  36. /*
  37. This code produces the following output.
  38.  
  39. The Array initially contains the following values:
  40.     [0]:    The
  41.     [1]:    quick
  42.     [2]:    brown
  43.     [3]:    fox
  44.     [4]:    jumps
  45.     [5]:    over
  46.     [6]:    the
  47.     [7]:    lazy
  48.     [8]:    dog
  49. After reversing:
  50.     [0]:    dog
  51.     [1]:    lazy
  52.     [2]:    the
  53.     [3]:    over
  54.     [4]:    jumps
  55.     [5]:    fox
  56.     [6]:    brown
  57.     [7]:    quick
  58.     [8]:    The
  59. */

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

5   голосов , оценка 3.6 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы