Код программы
var
x, L, M: integer;
procedure Calc(x: integer; var L: integer; var M: integer);
begin
L := 0;
M := 0;
while x > 0 do
begin
L := L + 1;
if M < (x mod 5) then
M := x mod 5;
X := x div 5;
end;
end;
begin
for x := 100 to 500 do
begin
Calc(x, L, M);
if (L = 3) and (M = 4) then
Println(x, L, M);
end;
end.
Вывод
100 3 4
101 3 4
102 3 4
103 3 4
104 3 4
105 3 4
106 3 4
107 3 4
108 3 4
109 3 4
110 3 4
111 3 4
112 3 4
113 3 4
114 3 4
115 3 4
116 3 4
117 3 4
118 3 4
119 3 4
120 3 4
121 3 4
122 3 4
123 3 4
124 3 4
суть процедуры заключается в том что она вычисляет кол-во цифр в 5ричном числе (L) и максимальну цифру в числе (М)
Максимальным для L=3 M=4 будет 124 или "444"_5
1.
using System;
public class Test
{
public static void Main()
{
int n;
double x, s=0;
Console.Write("n = ");
n = int.Parse(Console.ReadLine());
Console.Write("x = ");
x = double.Parse(Console.ReadLine());
for (int i=1; i <= n; i++) s = x*x/(2*i);
Console.WriteLine("s = {0}", s);
Console.ReadKey();
}
}
2.
using System;
public class Test
{
public static void Main()
{
int n, i=0;
double x, s=0;
Console.Write("n = ");
n = int.Parse(Console.ReadLine());
Console.Write("x = ");
x = double.Parse(Console.ReadLine());
while (i<n){
i++;
s = x*x/(2*i);
}
Console.WriteLine("s = {0}", s);
Console.ReadKey();
}
}
3.
using System;
public class Test
{
public static void Main()
{
int n, i=0;
double x, s=0;
Console.Write("n = ");
n = int.Parse(Console.ReadLine());
Console.Write("x = ");
x = double.Parse(Console.ReadLine());
do {
i++;
s = x*x/(2*i);
}
while (i<n);
Console.WriteLine("s = {0}", s);
Console.ReadKey();
}
}
Пример:
n = 5
x = 1.2
s = 0.144
Идем по схеме.
1) x=149
2) y=18
3) Проверяем условие x≥y. Условие истинно, идем по "Да".
4) x уменьшаем на величину y, получая х=149-18=131
5) идем к 3
Цикл 3)-5) повторяется, давая значения х, равные 113, 95, 77, 59, 41, 23, 5
6) Идем по "нет", проверив условие 5≥18 и выводим значение 5.
7) Завершаем работу.
Ответ: 5
Ответ:A2=11
A3=121
Объяснение:
Нам дано A1=5 B1=10 C1=18
Найти нам нужно A2 и A3
По условию A2=A1+6=5+6=11
A3=B2*A2=11*11=121
Почему B2 =11 потому что по условию, мы скопировали результат A2 в A4 B2 B3 B4 C2
PascalABC.NET 3.3.5, сборка 1659 от 09.04.2018
Внимание! Если программа не работает, обновите версию!
begin
var s:string; Writeln('Введите строку:'); Readln(s);
var s1:=ReadlnString('Что меняем:');
var s2:=ReadlnString('Чем заменить:');
s:=s.Replace(s1,s2);
Writeln('Результат'); Writeln(s)
end.
Пример
Введите строку:
(X > 0) and (Y < X) and (Z > Y) and (Z <> 5)
Что меняем: and
Чем заменить: &
Результат
(X > 0) & (Y < X) & (Z > Y) & (Z <> 5)