Advertisement
myname0

вложенные циклы_контестер_1.8

May 26th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7.  
  8. namespace ConsoleApplication
  9. {  
  10.     class Program
  11.     {
  12.         static long NOK(int a, int b, int c, int max)
  13.         {
  14.             long result = calcNok(a, b);
  15.             result = calcNok(result, c);
  16.             return result;
  17.         }
  18.  
  19.         static long calcNok(long num1,long num2)
  20.         {
  21.             return num1*num2/calcNod(num1,num2);
  22.         }
  23.  
  24.         static long calcNod(long a,long b)
  25.         {
  26.             return b == 0 ? a : calcNod(b, a % b);
  27.         }
  28.         static void Main(string[] args)
  29.         {
  30.             StreamReader fin = new StreamReader("input.txt");
  31.             string[] numb = fin.ReadLine().Split(' ');
  32.             fin.Close();
  33.             int a = int.Parse(numb[0]);
  34.             int b = int.Parse(numb[1]);
  35.             int c = int.Parse(numb[2]);
  36.             int max;
  37.             if ((a > b) && (a > c))
  38.                 max = a;
  39.             else max = b > c ? b : c;
  40.             StreamWriter fout = new StreamWriter("output.txt");
  41.             fout.Write("{0}", NOK(a, b, c, max));
  42.             fout.Close();
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement