class Program { static int div(int n, int n1, int sz) { int obj = 0; for (int i = 1; i < sz; i++)//вроде здесь ругается { if (n % i == 0 && n1 % i == 0) { obj = n / n1; } } int s = n / obj; int s1 = n1 / obj; if (s1==0 || s1==1) { return s; } Console.WriteLine("{0}/{1}", s, s1); return 1; } static void Main(string[] args) { Console.Write("Введите a: "); int n = Convert.ToInt32(Console.ReadLine()); Console.Write("Введите b: "); int n1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Введите диапозон: "); int sz = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Дробь {0}/{1} = ", div(n, n1, sz)); } } 

Here is my code, I do not know why it swears: (

  • @ 0xdb are you kidding? In the same place division on i by the following line. - Pavel Mayorov
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

Line error

 Console.WriteLine("Дробь {0}/{1} = ", div(n, n1, sz)); 

The format expects two parameters: {0} , {1}

Only one div(n, n1, sz)

  • Ahh sure, thanks) - SecDet