лабы 2 семестр / 7 лаба
.docЗадание:
1. В слове - четные буквы - гласные;
2. В слове, гласных букв больше, чем в следующем
слове в этой строке.
Программа:
Uses Crt;
Const K=2; L=7; M=20; N=10;
{Согласные}
Sogl: Set of Char = ['Б','В','Г','Д','Ж','З','К','Л','М','Н'
,'П','Р','С','Т','Ф','Х','Ц','Ч','Ш','Щ'];
{Гласные}
Gl: Set of Char = ['А','Е','И','О','У','Ы','Э','Ю','Я'];
Procedure PrintBegin;
Begin
TextBackground(0);
TextColor(7);
ClrScr;
GotoXY(30,1); WriteLn('Лабораторная 7');
WriteLn;
End;
Procedure PrintEnd(s:string; t:Byte);
Begin
GotoXY(1,25);
TextBackground(1);
TextColor(15);
ClrEol;
Write(s,' условию удовлетворяет: ',t,' слов');
End;
Var One,Two:Boolean; {Выполненность 1 и 2 условий}
i,j,h,d,s1,s2,t:Byte;
a:array[1..M,1..N,1..L] of Char;
Procedure ArrayBegin;
Begin
{Очистка массива}
For i:=1 to M Do
For j:=1 to N Do
For h:=1 to L Do
a[i,j,h]:=' ';
{Заполнение массива}
For i:=1 to M Do
For j:=1 to N Do
Begin
d:= Random(L-K+1)+K;
For h:=1 to d Do
a[i,j,h]:= Chr(Random(32)+128);
End;
End;
Procedure PrintWord(Cond:Boolean);
Begin
GotoXY((j-1)*8+1,i+2);
If Cond then
Begin
t:= t+1;
TextColor(14);
Write(a[i,j]:8);
TextColor(7);
End Else Write(a[i,j]:8);
End;
Procedure OneCondition;
Begin
ArrayBegin;
PrintBegin;
t:=0;
For j:=1 to N Do
For i:=1 to M Do
Begin
one:=True;
For h:=1 to l Do
if h mod 2 = 0 then
if not (a[i,j,h] in Gl) then
Begin
one:=False;
Break;
End;
{Вывод на экран}
PrintWord(One);
End;
PrintEnd('Первому',t);
if ReadKey<>#13 then Halt;
End;
Procedure TwoCondition;
Begin
ArrayBegin;
PrintBegin;
t:=0;
For j:=1 to N Do
Begin
s1:=0;
s2:=0;
For i:=1 to M Do
For h:=1 to L Do
Begin
if a[i,j,h] in Gl then s1:=s1+1;
if j<N then
if a[i,j+1,h] in Gl then s2:=s2+1;
End;
two:= s1>s2;
{Вывод на экран}
For i:=1 to M Do
PrintWord(Two);
End;
PrintEnd('Второму',t);
End;
Begin
Randomize;
Repeat
OneCondition;
TwoCondition;
Until ReadKey<>#13;
End.