Using System; namespace Fractions{ public struct Fraction : IComparable<Fraction> { public Fraction(int numerator, int denominator) { Numerator = numerator; Denominator = denominator; } public int Numerator; public int Denominator; public int CompareTo(Fraction other) { return (Numerator * other.Denominator).CompareTo(other.Numerator * Denominator); } } public class Program { static void Main(string[] args) { int numerator, denominator; Console.Write("Числитель первой дроби "); numerator = int.Parse(Console.ReadLine()); Console.Write("Знаменатель первой дроби "); denominator = int.Parse(Console.ReadLine()); var fraction1 = new Fraction(numerator, denominator); Console.Write("Числитель второй дроби "); numerator = int.Parse(Console.ReadLine()); Console.Write("Знаменатель второй дроби "); denominator = int.Parse(Console.ReadLine()); var fraction2 = new Fraction(numerator, denominator); var compareResult = fraction1.CompareTo(fraction2); if (compareResult < 0) Console.WriteLine("<"); else if (compareResult > 0) Console.WriteLine(">"); else // = 0 Console.WriteLine("="); } }}
Delphivar a1, a2: array of integer; n, c, i: integer; procedure PrintDescending(a: array of integer); var i, j, max: integer; begin for i := 0 to Length(a) - 1 do begin for j := 0 to Length(a) - 1 do if a[j] > a[max] then max := j; Write(a[max], ' '); a[max] := -10001; end; end; begin //Запрашиваем ввод длины массива: Write('Введите длину массива: '); Read(n); //Устанавливаем длину массивов: SetLength(a1, n); SetLength(a2, n); //Заполняем первый массив случайными числами: for i := 0 to n - 1 do a1[i] := Random(201) - 100; //Заполняем второй массив только нечётными элементами первого: for i := 0 to n - 1 do if Abs(a1[i]) mod 2 = 1 then begin a2[c] := a1[i]; c := c + 1; end; //Урезаем второй массив: SetLength(a2, c); //Выводим первый массив: for i := 0 to n - 1 do Write(a1[i], ' '); Writeln; //Выводим второй массив в порядке убывания: if c = 0 then Write('Нечётных элементов нет.') else PrintDescending(a2); end.
1024*128=131072вооот