Advertisement
Guest User

7 Расширение массива (9 баллов)

a guest
May 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Rasshirenie_massiva
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.            
  10.  
  11.  
  12.             {
  13.                 Console.WriteLine("Введите 6 чисел через пробел ");
  14.                 string s = Console.ReadLine();
  15.                 string[] array = s.Split();
  16.  
  17.                 Console.WriteLine("Введите команду summ");
  18.                 string command = Console.ReadLine();
  19.  
  20.                 if (command == "summ")
  21.                 {
  22.                    
  23.                     int sum = 0;
  24.                     for (int i = 0; i < array.Length; i++)
  25.                     {
  26.                        
  27.                         sum += Convert.ToInt32(array[i]);
  28.                         Console.Write(array[i] + " ");
  29.                     }
  30.  
  31.                     Console.WriteLine();
  32.                     Console.WriteLine("Сумма = " + (sum));
  33.  
  34.                     Console.WriteLine("Введите команду sort");
  35.                     command = Console.ReadLine();
  36.  
  37.                         if (command == "sort")
  38.                         {
  39.                         Array.Sort(array);
  40.  
  41.                         foreach (string n in array)
  42.  
  43.                             Console.WriteLine(n);
  44.                         }
  45.  
  46.                 }
  47.                
  48.                
  49.  
  50.                 else
  51.                     Console.WriteLine("NO! Введите команду summ");
  52.                
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement