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("="); } }}
А)
program c1;
var
a, b: integer;
c: real;
begin
a := 2;
b := 3;
c := a + 1 / 3;
write(c);
end.
Б)
program c2;
var
a, b: integer;
c: real;
begin
a := 2;
b := 3;
c := a + 4 / 2 * 3 + 6;
write(c);
end.
В)
program c3;
var
a, b: integer;
c: real;
begin
a := 2;
b := 3;
c := a + 4 / 2 * 3;
write(c);
end.
Объяснение:
А)
program c1; // Название программы
var // Раздел для описания переменных
a, b: integer; // Объявление целочисленных переменных
c: real; // Объявление вещественной переменной
begin // Начало программы
a := 2; // a = 2
b := 3; // b = 3
c := a + 1 / 3; // c = a + 1 ÷ 3
write(c); // Выводим ответ
end. // Конец программы
Б)
program c2; // Название программы
var // Раздел для описания переменных
a, b: integer; // Объявление целочисленных переменных
c: real; // Объявление вещественной переменной
begin // Начало программы
a := 2; // a = 2
b := 3; // b = 3
c := a + 4 / 2 * 3 + 6; // c = a + 4 ÷ 2 × 3 + 6
write(c); // Выводим ответ
end. // Конец программы
В)
program c3; // Название программы
var // Раздел для описания переменных
a, b: integer; // Объявление целочисленных переменных
c: real; // Объявление вещественной переменной
begin // Начало программы
a := 2; // a = 2
b := 3; // b = 3
c := a + 4 / 2 * 3; // c = a + 4 ÷ 2 × 3
write(c); // Выводим ответ
end. // Конец программы