На С#
На будівництво водопроводу застосовуються труби довжиною p і 20 м (p>20). Потрібно прокласти S км водопроводу. Скільки труб кожного типу знадобиться і якої довжини трубу треба буде додати, щоб закінчити роботу. Значення змінних p та S ввести з клавіатури.

Ответы

Ответ дал: asilvejstruk
1

using System;

class MainClass {

 public static void Main (string[] args) {

   int p, S, pipes20, pipesP;

   int remainder;

   Console.WriteLine("Enter the length of the pipes (p) in meters: ");

   p = Convert.ToInt32(Console.ReadLine());

   Console.WriteLine("Enter the total length of the water supply needed in kilometers: ");

   S = Convert.ToInt32(Console.ReadLine());

   pipes20 = S * 1000 / 20;

   pipesP = S * 1000 / p;

   remainder = (S * 1000) % p;

   Console.WriteLine("Number of 20m pipes needed: " + pipes20);

   Console.WriteLine("Number of " + p + "m pipes needed: " + pipesP);

   Console.WriteLine("Additional " + remainder + "m pipe needed to complete the work.");

 }

}

Вас заинтересует