Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static string div(int a, int b)
- {
- int a_cop = a;
- int b_cop = b;
- while (a > 0 && b > 0)
- {
- if (a > b)
- {
- a %= b;
- }
- else
- {
- b %= a;
- }
- }
- int nod = a + b;
- if (a_cop > b_cop)
- {
- return nod.ToString();
- }
- else
- return string.Format("{0}/{1}", a_cop/nod,b_cop/nod);
- }
- static void Main()
- {
- Console.Write("Введите a: ");
- int n = Convert.ToInt32(Console.ReadLine());
- Console.Write("Введите b: ");
- int n1 = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Дробь a/b ={0} ", div(n, n1));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment