Files
learning/PascalABCnet/массивы/сравнение char и массива с char.pas
2025-11-20 21:18:32 +02:00

25 lines
1.1 KiB
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
program nunax;
var c:char;
ch : array[1..4] of char;
i,x:integer;
label l1;
begin
ch[1]:='a';
ch[2]:='b';
ch[3]:='c';
ch[4]:='d'; //записываю переменные в массив
l1: // метка для того чтобы при вводе неверного варианта что то происходило
x:=0; //всегда обнуляй переменные при использовании циклов
WriteLn('введи a,b,c или d');
ReadLn(c); //считывание варианта
for i:=1 to 4 do
begin
if (c<>ch[i]) then inc(x); // тут вариант сравнивается с a b c и d которые внесены в массив
end; // если inc(x) произошло 4 раза, значит вариант не равен ничему из того что есть в массиве
if x<>3 then
begin
Writeln('че?');
goto l1; // собственно сам переход к l1 если введен неверный вариант
end;
WriteLn('end');
end.