unit
Uni097u89;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class
(TForm)
Input: TMemo;
Output: TMemo;
procedure
InputChange(Sender: TObject);
private
public
end
;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure
TForm1
.
InputChange(Sender: TObject);
var
buf:
string
;
i,n,z,k:
Integer
;
S :
AnsiString
;
A :
array
[
0..31
]
of
AnsiString
;
O, r :
Boolean
;
begin
O :=
False
;
n :=
0
;
A[n] :=
''
;
Output
.
Lines
.
Clear();
S := Input
.
Lines
.
Text;
if
(Input
.
Lines
.
Count >
0
)
and
(S[Length(S)] =
'.'
)
and
(Pos(
'.'
,S) = Length(S))
then
begin
for
i :=
1
to
Length(S)
do
begin
if
S[i] =
' '
then
begin
if
(Length(A[n]) >=
1
)
and
(Length(A[n]) <=
10
)
then
begin
n := n +
1
;
A[n] :=
''
;
end
else
if
A[n] <>
''
then
begin
Output
.
Lines
.
Text :=
'Слова должны содержать от 1 до 10 букв'
;
O :=
True
;
Break;
end
;
end
else
if
S[i] =
'.'
then
begin
if
(n <
1
)
or
(n >
28
)
then
begin
O :=
True
;
Output
.
Lines
.
Text :=
'Колличество слов менее 2 или более 30'
;
end
else
if
Length(A[n]) >
10
then
begin
Output
.
Lines
.
Text :=
'Слова должны содержать от 1 до 10 букв'
;
O :=
True
;
Break;
end
;
Break;
end
else
try
begin
k := StrToInt(S[i]);
end
except
A[n] := A[n] + Copy(S,i,
1
);
end
;
end
;
if
O =
False
then
begin
O :=
True
;
for
i :=
1
to
Length(A)
do
begin
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Output
.
Lines
.
Add(A[i]);
O :=
False
;
end
;
if
O =
True
then
begin
Output
.
Lines
.
Text :=
'Слов, отличных от последнего не найдено'
;
end
;
end
else
begin
Output
.
Lines
.
Text :=
'Напишите 2 - 30 слов в поле ввода.'
;
Output
.
Lines
.
Add(
'Слова разделяются пробелом, в конце ставится точка.'
);
end
;
end
;
end
;
end
.