Другие языки программирования и технологии

C# Нужно разместить 3 числа по возрастанию.

Вот заготовка... using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.DarkYellow; int x, y, z; Console.WriteLine("Введіть значення х = "); x = int.Parse(Console.ReadLine()); Console.WriteLine("x = " + x); Console.WriteLine("Введіть значення y = "); y = int.Parse(Console.ReadLine()); Console.WriteLine("y = " + y); Console.WriteLine("Введіть значення z = "); z = int.Parse(Console.ReadLine()); Console.WriteLine("z = " + z); } } }
// Zvezdochot
using System;

namespace Zvezdochot
{
class Program
{
static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.DarkYellow;
int x, y, z, max, min, middle;
Console.Write("Введите значение х = ");
x = int.Parse(Console.ReadLine());

Console.Write("Введите значение y = ");
y = int.Parse(Console.ReadLine());

Console.Write("Введите значение z = ");
z = int.Parse(Console.ReadLine());

max = (x > y) ? (x > z) ? x : z : (y > z) ? y : z;
min = (x < y) ? (x < z) ? x : z : (y < z) ? y : z;
if ((x == min || x == max) && (y == min || y == max)) middle = z;
else if ((x == min || x == max) && (z == min || z == max)) middle = y;
else middle = x;

Console.Write(min + " ");
Console.Write(middle + " ");
Console.Write(max);

Console.ReadKey();
}
}
}
Игорь Литтау
Игорь Литтау
92 279
Лучший ответ
Вадим Раевский спс. Уважуха)))
using System;
using System.Collections.Generic;
using System.Text;

namespace sort
{
class Program
{
static void Main(string[] args)
{
int [] a = new int [3];
for (int i = 0; i < 3; i++)
a [ i ] = Int32.Parse(Console.ReadLine());
Array.Sort(a);
PrintArray(a);
}
static void PrintArray(int [] a)
{
for (int i = 0; i < a.Length; i++)
Console.WriteLine(a [ i ] );
}
}
}
Рол Иван
Рол Иван
1 394
а не проще в массив числа загнать и массив отсортировать?? ? нафиг три инта?? ? причем тут Console.BackgroundColor??? если главная задача не решена, зачем эти.... выкрутасы?? ?

Console.ForegroundColor = ConsoleColor.DarkYellow;....дизайнеры... .

прочитай в сети про быструю сортировку, сортировку пузырьком, вставками.. . и др. там же и код возьмешь. лень копипастить.

Похожие вопросы