Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1.  static public string Sokr()
  2.         {
  3.             Console.WriteLine("Введіть чисельник");
  4.             int сh = Convert.ToInt32(Console.ReadLine());
  5.             Console.WriteLine("Введіть знаменник");
  6.             int zn = Convert.ToInt32(Console.ReadLine());
  7.             int nod = 0;
  8.  
  9.  
  10.             for (int i = 1; i < (сh * zn + 1); i++)
  11.             {
  12.                 if (zn % i == 0 && сh % i == 0)
  13.                 {
  14.                     nod = i;
  15.                 }
  16.             }
  17.             сh = сh / nod;
  18.             zn = zn / nod;
  19.             string strCh = Convert.ToString(сh);
  20.             string strZn = Convert.ToString(zn);
  21.             string s = strCh + "/" + strZn;
  22.             Console.WriteLine(s);
  23.             return s;
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement