Advertisement
Pavle_nis

C# Console App2

Oct 10th, 2017
146
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 ConsoleApp6
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] a; ;
  14.             Console.WriteLine("Unesi velicinu niza: ");
  15.             int n = Convert.ToInt32(Console.ReadLine());
  16.             a = new int[n];
  17.  
  18.             for(int i = 0; i < a.Length; i++)
  19.                 a[i] = Convert.ToInt32(Console.ReadLine());
  20.  
  21.             Array.Sort(a);
  22.  
  23.             Console.WriteLine("Od manjeg ka vecem:");
  24.             for (int i = 0; i < a.Length; i++)
  25.                 Console.WriteLine(a[i]);
  26.  
  27.             Array.Sort(a, (x, y) => y.CompareTo(x));
  28.  
  29.             Console.WriteLine("Od veceg ka manjem:");
  30.             for (int i = 0; i < a.Length; i++)
  31.                 Console.WriteLine(a[i]);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement