Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication3
- {
- class Program
- {
- static void Main(string[] args)
- {
- try
- {
- Console.WriteLine("Podaj wartość x:");
- int x = int.Parse(Console.ReadLine());
- Console.WriteLine("Podaj wartość y:");
- int y = int.Parse(Console.ReadLine());
- Console.WriteLine("Podaj wartość z:");
- int z = int.Parse(Console.ReadLine());
- string order = "";
- Console.WriteLine("Jak posortować ?");
- Console.WriteLine("1. Sortowanie rosnące");
- Console.WriteLine("2. Sortowanie malejące");
- ConsoleKeyInfo key = Console.ReadKey();
- if(key.Key == ConsoleKey.D1)
- Console.WriteLine(order);
- Console.ReadKey();
- }
- catch (Exception ex)
- {
- Console.WriteLine("Błąd aplikacji: {0} - {1} |{2}", ex.Message);
- }
- }
- static string SortAsceding(int x, int y, int z)
- {
- try {
- string order = "Posortowane rosnąco: {0],{1},{2}";
- if (x > y)
- {
- if (x > z)
- {
- if (y > z)
- {
- order = string.Format("{0},{1},{2}", z, y, x);
- }
- else
- {
- order = string.Format("{0},{1},{2}", y, z, x);
- }
- }
- else
- {
- order = string.Format("{0},{1},{2}", y, x, z);
- }
- }
- else {
- if (y > z)
- {
- if (x > z)
- {
- order = string.Format("{0},{1},{2}", z, x, y);
- }
- else
- {
- order = string.Format("{0},{1},{2}", x, z, y);
- }
- }
- else
- {
- order = string.Format("{0},{1},{2}", x, y, z);
- }
- return (order);
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("Błąd aplikacji: {0} - {1} | {2}", ex.Message);}
- return null;
- }
- static string SortDescending(int x, int y, int z)
- {
- try
- {
- string order = "Posortowane malejąco: {0],{1},{2}";
- if (x > y)
- {
- if (x > z)
- {
- if (y > z)
- {
- order = string.Format("{0},{1},{2}", x, y, z);
- }
- else
- {
- order = string.Format("{0},{1},{2}", x, z, y);
- }
- }
- else
- {
- order = string.Format("{0},{1},{2}", z, x, y);
- }
- }
- else
- {
- if (y > z)
- {
- if (x > z)
- {
- order = string.Format("{0},{1},{2}", y, x, z);
- }
- else
- {
- order = string.Format("{0},{1},{2}", y, z, x);
- }
- }
- else
- {
- order = string.Format("{0},{1},{2}", z, y, x);
- }
- return (order);
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("Błąd aplikacji: {0} - {1} | {2}", ex.Message);
- }
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement