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 ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- /* int a, b;
- A:
- Console.WriteLine("Podaj a.");
- a = int.Parse(Console.ReadLine());
- Console.WriteLine("Podaj b.");
- b = int.Parse(Console.ReadLine());
- if (a == 0 || b == 0) { Console.WriteLine("Błędna liczba! "); goto A; }
- while (a != b)
- {
- if (a > b)
- a -= b;
- else
- b -= a;
- }
- Console.WriteLine("Największy wspólny dzielnik (NWD) to: " + a);
- Console.ReadKey(); */
- int a, b;
- while (true)
- {
- Console.WriteLine("Podaj a.");
- a = int.Parse(Console.ReadLine());
- Console.WriteLine("Podaj b.");
- b = int.Parse(Console.ReadLine());
- if (a == 0 || b == 0) Console.WriteLine("Błędna liczba! ");
- else break;
- }
- while (a != b)
- {
- if (a > b)
- a -= b;
- else
- b -= a;
- }
- Console.WriteLine("Największy wspólny dzielnik (NWD) to: " + a);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement