//PascalABC.Netfunction DelWord(s:string):string;var i,n:integer;begin n:=length(s); i:=n; repeat if i>=1 then Dec(i); until s[i]=' '; Delete(s,i+1,n-i); DelWord:=send;var st:string;begin Write('Введите строку: '); Readln(st); Writeln('Результат: ',DelWord(st))end.
Тестовое решение:Введите строку: А роза упала на лапу АзораРезультат: А роза упала на лапу
//PascalABC.Netfunction DescDigits(s:string):boolean;var desc:boolean; i,n:integer; c1,c2:char;begin n:=length(s); desc:=true; c1:='A'; { главное, чтобы символ был "старше" любой цифры } i:=1; repeat c2:=s[i]; if c2 in ['0'..'9'] then if c2<c1 then c1:=c2 else desc:=false; Inc(i) until (i>n) or (not desc); DescDigits:=descend;var s:string;begin Write('Введите строку: '); Readln(s); if DescDigits(s) then Writeln('true') else Writeln('false')end.
Тестовое решение:Введите строку: Пример строки с цифрами 98 по убыванию 7 6,5, так4тоже1можно!true
Вариант первой программы для Borland Pascal 7.01uses Crt;function DelWord(s:string):string;var i,n:integer;begin n:=length(s); i:=n; repeat if i>=1 then Dec(i); until s[i]=' '; Delete(s,i+1,n-i); DelWord:=send;var st:string;begin ClrScr; Write('Введите строку: '); Readln(st); Writeln('Результат: ',DelWord(st)); ReadKeyend.