gospod1978

List\List of Products

Oct 17th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace fundamental14
  6. {
  7.     class MainClass
  8.     {
  9.         public static void Main()
  10.         {
  11.             int number = int.Parse(Console.ReadLine());
  12.             List<string> products = new List<string>();
  13.        
  14.        for (int i = 0; i < number; i++)
  15.        {
  16.        
  17.         products.Add(Console.ReadLine());
  18.        
  19.         }
  20.         products.Sort();
  21.        
  22.        for (int i = 0; i < products.Count; i++)
  23.        {
  24.         Console.WriteLine($"{i + 1}.{products[i]}");
  25.        }
  26.      
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment