Username77177

Nure-Programming-ControlWork1E4-6

Oct 25th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ControlWork1
  4. {
  5.     class Fourthexercise
  6.     {
  7.         public static void fo_ex()
  8.         {
  9.             //Fill the array
  10.             Console.WriteLine("Введите числа (5 штук)");
  11.             int[] array1 = new int[5];
  12.             for (int i = 0; i < array1.Length; i++)
  13.             {
  14.                 Console.WriteLine("Введите число (осталось " + (5 - i) + ")");
  15.                 array1[i] = Convert.ToInt32(Console.ReadLine());
  16.             }
  17.  
  18.             //Sorting
  19.             int biggerthanarray = array1[0];
  20.             foreach (var item in array1)
  21.             {
  22.                 if (item > biggerthanarray)
  23.                 {
  24.                     biggerthanarray = item;
  25.                 }
  26.             }
  27.  
  28.             Console.WriteLine("Наибольшее число в данном массиве: " + biggerthanarray + "\nЕго индекс: " + Array.IndexOf(array1, biggerthanarray));
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment