DrSmile

Методы ввода массива с клавиатуры и вывод

Jun 17th, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 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 ConsoleApp10
  8. {
  9.     class Program
  10.     {
  11.         static int[] Input()
  12.         {
  13.             const int len= 5;
  14.             int[] massive = new int[len];
  15.             for(int i=0;i<massive.Length;i++)
  16.             {
  17.                 Console.Write("Введите " + i + " число: ");
  18.                 massive[i] = int.Parse(Console.ReadLine());
  19.             }
  20.             return massive;
  21.         }
  22.         static void Output(int[] massive)
  23.         {
  24.            for(int i=0;i<massive.Length;i++)
  25.             {
  26.                 Console.WriteLine(i + " значение=" + massive[i]);
  27.             }
  28.         }
  29.  
  30.  
  31.  
  32.         static void Main(string[] args)
  33.         {
  34.             int[] massive=Input();
  35.             Output(massive);
  36.         }
  37.     }
  38. }
Add Comment
Please, Sign In to add comment