unit SpaceLib;
interface
uses System;
const
ch = ' ';
function MyTrimLeft(s: string): string;
function MyTrimRight(s: string): string;
function MyTrim(s: string): string;
function MySingleSpaces(s: string): string;
function MyNoSpaces(s: string): string;
implementation
function MyTrimLeft(s: string): string;
begin
MyTrimLeft := Regex.Replace(s, '^[' + ch + ']+', '');
end;
function MyTrimRight(s: string): string;
begin
MyTrimRight := Regex.Replace(s, '[' + ch + ']+$', '');
end;
function MyTrim(s: string): string;
begin
s := Regex.Replace(s, '^[' + ch + ']+', '');
MyTrim := Regex.Replace(s, '[' + ch + ']+$', '');
end;
function MySingleSpaces(s: string): string;
begin
s := MyTrim(s);
MySingleSpaces := Regex.Replace(s, '[' + ch + ']+', ' ');
end;
function MyNoSpaces(s: string): string;
begin
MyNoSpaces := s.Replace(ch, '');
end;
end.
//PascalABC.NET версия 3.4.0.1677 от 17.06.18
//Если программа не запускается, то обновите версию
uses SpaceLib;
begin
var s := ' 123 123 23 4343 434 43 34 ';
WritelnFormat('"{0}"', MyTrimLeft(s));
WritelnFormat('"{0}"', MyTrimRight(s));
WritelnFormat('"{0}"', MyTrim(s));
WritelnFormat('"{0}"', MySingleSpaces(s));
WritelnFormat('"{0}"', MyNoSpaces(s));
end.
var a,b,c: integer;
begin
write('Введите пятизначное число:');
readln(c);
if (c >= 10000) and (c <= 99999) then
begin
a:=c;
while a>0 do
begin
b:=b*10+a mod 10;
a:=a div 10
end;
writeln ('Вы ввели число: ',c);
write ('Переворот числа: ',b)
end
else
begin
writeln('Число не пятизначное');
writeln ('Вы ввели число: ',c)
end
end.
Или всё через if:
var a,b,c: integer;
begin
write('Введите пятизначное число:');
readln(c);
if (c >= 10000) and (c <= 99999) then
begin
a:=c;
if a>0 then
begin
b:=b*10+a mod 10;
a:=a div 10
end;
if a>0 then
begin
b:=b*10+a mod 10;
a:=a div 10
end;
if a>0 then
begin
b:=b*10+a mod 10;
a:=a div 10
end;
if a>0 then
begin
b:=b*10+a mod 10;
a:=a div 10
end;
if a>0 then
begin
b:=b*10+a mod 10;
a:=a div 10
end;
writeln ('Вы ввели число: ',c);
write ('Переворот числа: ',b)
end
else
begin
writeln('Число не пятизначное');
writeln ('Вы ввели число: ',c)
end
end.
Программа на python
Объяснение:
print("Привет мой дорогой друг!")
print("Привет!")
print(" решить задачу: a=b*5")
b = int(input("Хорошо, введи значение b:"))
b *= 5
print(" ответ=", b, sep='')