Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LNKO
- {
- class Program
- {
- static void Main(string[] args)
- {
- int m, n;
- do
- {
- Console.WriteLine("Adj meg egy egész számot!");
- m = int.Parse(Console.ReadLine());
- } while (m == 0);
- if (m < 0)
- {
- m = m * -1;
- }
- do
- {
- Console.WriteLine("Adj meg még egy egész számot!");
- n = int.Parse(Console.ReadLine());
- } while (n == 0);
- if (n < 0)
- {
- n = n * -1;
- }
- if (m < n) //ha m kisebb mint n, akkor m és n értékének kicserélése
- {
- int r;
- r = m;
- m = n;
- n = r;
- }
- while (m % n > 0)
- {
- int z = m % n;
- m = n;
- n = z;
- }
- Console.WriteLine("A két szám legnagyobb közös osztója: " + n);
- Console.ReadKey();
- }//Main fv. vége
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement