Answer the question
In order to leave comments, you need to log in
Why does a pascal program run indefinitely?
There are three digits: 1, 3, 7. Of these, numbers are made up in ascending order (1, 3, 7, 11, 13, etc.) You need to find the Nth number in a row. Here is the code:
Program Numbers_Maysen;
var N,k,c,i,flag: integer; s:string; label 1;
begin
read(N);
c:=0;
k:=0;
repeat
1: c:= c + 1;
str(c, s);
for i:=1 to length(s) do begin
if pos('1', s[i])=1 then
flag:= 1 else
flag:=0;
if flag = 0 then goto 1 else
if pos('3', s[i])=1 then
flag:= 1 else
flag:=0;
if flag = 0 then goto 1 else
if pos('7', s[i])=1 then
flag:= 1 else
flag:=0;
if flag = 0 then goto 1 else
if flag = 1 then k:=k+1;
end;
until k = N;
writeln(k);
end.
Answer the question
In order to leave comments, you need to log in
Without delving into the code itself, I can advise:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question