Created
November 1, 2019 16:50
-
-
Save leequixxx/c98df567fc33f834811027e48c78f809 to your computer and use it in GitHub Desktop.
Лабалаторная работа 4. Задание 2. Вариант 6.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program Project1; | |
{$MODE DELPHI} | |
uses | |
SysUtils; | |
const STOP_CHARACTER = 's'; | |
var count: Integer; | |
var counts: array of Integer; | |
var i, j: Integer; | |
var str: String; | |
var allOk: Boolean; | |
var symbolsCount: Integer; | |
begin | |
while True do | |
begin | |
try | |
Write('Please, enter count of strings: '); | |
ReadLn(count); | |
break; | |
except | |
on E: Exception do | |
begin | |
WriteLn('Count value should be a number'); | |
continue; | |
end; | |
end; | |
end; | |
SetLength(counts, count); | |
for i := 0 to count - 1 do | |
begin | |
while True do | |
begin | |
allOk := false; | |
Write('Please, enter string #', i + 1, ': '); | |
ReadLn(str); | |
symbolsCount := 0; | |
for j := 1 to Length(str) do | |
begin | |
if str[j] = STOP_CHARACTER then | |
begin | |
symbolsCount := symbolsCount + 1; | |
counts[i] := j - 1; | |
allOk := true; | |
end; | |
end; | |
if Not allOk then | |
begin | |
WriteLn('String should has "', STOP_CHARACTER, '" character'); | |
continue; | |
end; | |
if symbolsCount <> 1 then | |
begin | |
WriteLn('String should has only one "', STOP_CHARACTER,'" character'); | |
continue; | |
end; | |
Break; | |
end; | |
end; | |
Write('Sizes: '); | |
for i := 0 to count - 1 do | |
begin | |
Write(counts[i], ' '); | |
end; | |
WriteLn; | |
WriteLn('Enter something for exit...'); | |
ReadLn; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment