Другие языки программирования и технологии
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();
}
}
}
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();
}
}
}
Вадим Раевский
спс. Уважуха)))
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 ] );
}
}
}
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 ] );
}
}
}
а не проще в массив числа загнать и массив отсортировать?? ? нафиг три инта?? ? причем тут Console.BackgroundColor??? если главная задача не решена, зачем эти.... выкрутасы?? ?
Console.ForegroundColor = ConsoleColor.DarkYellow;....дизайнеры... .
прочитай в сети про быструю сортировку, сортировку пузырьком, вставками.. . и др. там же и код возьмешь. лень копипастить.
Console.ForegroundColor = ConsoleColor.DarkYellow;....дизайнеры... .
прочитай в сети про быструю сортировку, сортировку пузырьком, вставками.. . и др. там же и код возьмешь. лень копипастить.
Похожие вопросы
- Задача даны числа 1,3,5,7,9,11,13,15 Нужно взять 3 числа и ТОЛЬКО сложением получить 30
- Не могу опредилиться между C++ и C#, с чего начать программировать. Вот знаю например что в C++ нужно самим управлять...
- Как можно написать программу на языке C, которая будет выводить числа от 1 до 1000 без if, switch, do, while, for, goto?
- c++. нужно нарисовать такую матрицу.
- C++, я ввожу двухзначное число, как мне объяснить программе, что первое число это десятки, а второе единицы?
- C++ long double большие числа при умножении искажаются
- Кто знает язык C++ нужно пояснить что означает каждая строчка програмы
- c++, как отрандомить случайное число типа float в диапазоне от 0 до 10 ? (пример - 0,42; 7,71)
- В паскале нужно разбить целое число на три слогаемых, всевозможными способами.
- C++ Даны три действительных числа. Возвести в квадрат те из них, значения которых неотрицательны.