Приведите пример одной строки описания нескольких переменных вещественного типа в языке Паскаль (в программе проверить на допустимость первый символ каждого идентификатора)
Т.е. если вводится допустим var a1,b34:real; должно выводиться что всё верно, а если например var a1,34d:real; должно выводиться сообщение об ошибке.
Получилось у меня то что приведено ниже..Но есть проблема. Проверяет он мне только первое обозначение переменной, т.е. в обоих примерах a1. И радостно пишет и там и там верно =( И ещё.. если выводится 'stroka vvedena ne verno! oshibcka peremen.', то программа зацикливается. Не могу найти ошибки( Помогите, пожалуйста. Заранее благодарю.
Код
Program Vopr;
uses crt;
procedure PDellB(var s:string);
begin
while (s>'')and (s[1]=' ') do
delete (s,1,1);
end;
var s,s1,c1,c2,c3,r:string;
l1,l2,l3,i,i1,l,k,j,n,x,m:byte;
begin
c1:='var '; c2:=':real;';
c3:='1234567890,.!@#$^&*(){}[]-_=+~';
l1:=length(c1); l2:=length(c2); l3:=length(c3);
m:=0;
while m<3 do begin
writeln('Vvedite primer odnoj stroki opisaniya neskolkih peremennyh veschestvennogo tipa: ');
writeln('Dlya spravki naberite "?"');
readln(s);
{$v-}PDellB(s); {v+}
if s=('?') then begin
textcolor(yellow);
writeln('Красным указана обязательная часть, синим не обязательная');
writeln('значения в скобках описание переменных начинающихся латинской буквой');
textcolor(red); write('var '); textcolor(blue);
write('[...]'); textcolor(red); writeln(':real;'); textcolor(white);
end;
i:=pos(c1,s); i1:=pos(c2,s);
if (i=0) or (i1=0) then begin writeln('primer ne vernyj!'); m:=m+1; end
else begin
if i>i1 then begin writeln('primer ne vernyj! nepr.posled.ident.');
m:=m+1; end
else begin
delete(s,i,l1);
i1:=pos(c2,s);
delete(s,i1,l2);
r:=',';
l:=length(s);
while l<>0 do begin
j:=pos(r,s);
s1:=copy(s,1,j); delete(s,1,length(s1));
for n:=1 to l3 do begin
k:=pos(s1[1],c3[n]);
if k<>0 then begin writeln('stroka vvedena ne verno! oshibcka peremen.'); {???}
l3:=l3+1; l:=0; m:=m+1; end
else n:=n+1;
end;
l:=length(s);
if l=0 then begin writeln('Verno!'); m:=5; end;
end;
end;
end;
end;end.
uses crt;
procedure PDellB(var s:string);
begin
while (s>'')and (s[1]=' ') do
delete (s,1,1);
end;
var s,s1,c1,c2,c3,r:string;
l1,l2,l3,i,i1,l,k,j,n,x,m:byte;
begin
c1:='var '; c2:=':real;';
c3:='1234567890,.!@#$^&*(){}[]-_=+~';
l1:=length(c1); l2:=length(c2); l3:=length(c3);
m:=0;
while m<3 do begin
writeln('Vvedite primer odnoj stroki opisaniya neskolkih peremennyh veschestvennogo tipa: ');
writeln('Dlya spravki naberite "?"');
readln(s);
{$v-}PDellB(s); {v+}
if s=('?') then begin
textcolor(yellow);
writeln('Красным указана обязательная часть, синим не обязательная');
writeln('значения в скобках описание переменных начинающихся латинской буквой');
textcolor(red); write('var '); textcolor(blue);
write('[...]'); textcolor(red); writeln(':real;'); textcolor(white);
end;
i:=pos(c1,s); i1:=pos(c2,s);
if (i=0) or (i1=0) then begin writeln('primer ne vernyj!'); m:=m+1; end
else begin
if i>i1 then begin writeln('primer ne vernyj! nepr.posled.ident.');
m:=m+1; end
else begin
delete(s,i,l1);
i1:=pos(c2,s);
delete(s,i1,l2);
r:=',';
l:=length(s);
while l<>0 do begin
j:=pos(r,s);
s1:=copy(s,1,j); delete(s,1,length(s1));
for n:=1 to l3 do begin
k:=pos(s1[1],c3[n]);
if k<>0 then begin writeln('stroka vvedena ne verno! oshibcka peremen.'); {???}
l3:=l3+1; l:=0; m:=m+1; end
else n:=n+1;
end;
l:=length(s);
if l=0 then begin writeln('Verno!'); m:=5; end;
end;
end;
end;
end;end.