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("="); } }}
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("="); } }}