Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Напишете програма която приема вход от клавиатурата две положителни числа m и n
- * и отпечатва цялата част и остатъка при делението на m със n.
- * Използвайте операция изваждане и цикъл при решаването на задачата
- * (не използвайте оператори / и %) */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _4.EX
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("m = ");
- int dividend = Int32.Parse(Console.ReadLine()); //dividend = делимо
- Console.Write("n = ");
- int divisior = Int32.Parse(Console.ReadLine()); //divisior = делител
- int quotient = 0; // quotient = частно
- while (dividend >= divisior) // докато делимото е >= на делителят прави :
- {
- dividend -= divisior; // делимо = делимо - делител
- quotient++; // увеличи quitient с единица
- }
- Console.WriteLine("quotient: {0}", quotient);
- Console.WriteLine("remainder: {0}", dividend);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment