volvo, смотри: Чтоб сразу нельзя было сохранять деньги я сначала сделал вот так
Код
uses crt;
const N=1000;
label start1,save, view,view1, start, money, exit;
type
Dengi=record
name:string[9];
babki:word;
end;
var
b,flag:boolean; {<--- Обрати внимание}
imya:string[15];
x,y,rez:byte;
tmp:word;
mas: array[1..N] of dengi;
otv,otvet:char;
i,j,sum,stavka,count:integer;
f:text;
begin {start1:}
textbackground(1);
textcolor(10);
clrscr;
start1:count:=0;
assign(f,'123.txt');
reset(f);
begin
while (not eof(f)) do
begin
inc(count);
readln(f,mas[count].name);
readln(f,mas[count].babki);
end;
end;
close(f);
flag:=false; {<--}
writeln;
writeln(' ------------- -------- --------------- ');
writeln(' |1-ЌЋ‚›‰ €ѓђЋЉ| |2-€ѓђЋЉ€| |3-‚›•Ћ„ €‡ €ѓђ›|');
writeln(' ------------- -------- --------------- ');
writeln;
otvet:=readkey;
if otvet='1' then begin
writeln;
writeln(' Љ Є вҐЎп §®ўгв ?я');
writeln;
readln(imya);
end;
if otvet='2' then goto view1;
if otvet='3' then goto exit;
randomize;
sum:=100;
writeln;
writeln( ' Ћђ…‹ €‹€ ђ…˜ЉЂ ');
while sum>0 do
begin
if sum>=1000 then
begin
writeln;
writeln(' Њ®Ґ Є §Ё® ®Ў Єа®вЁ«®бм, в Є зв® Ё¤Ё Є вл ®вбо¤ Ї®Є п вҐЎп Ґ гЎЁ«');
writeln;
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
delay(65000); delay(65000);
goto save;
end;
start:
writeln;
writeln(' -------- --------- ---------- ------------------ ----------------- ');
writeln('| 0-Ћђ…‹ | | 1-ђ…˜ЉЂ | | 2-€ѓђЋЉ€ | | 3-‡ЂЃђЂ’њ „…Ќњѓ€ | | 4-‚›•Ћ„ €‡ €ѓђ› | ');
writeln(' -------- --------- ---------- ------------------ ----------------- ');
writeln;
otv:=readkey;
if otv>'4' then
begin
writeln;
writeln(' ” ⥡п ᮢᥬ Ї«®е® б® §аҐЁҐ¬ ? Ќ ЇЁб ® ¦Ґ: ');
writeln;
writeln(' -------- --------- ---------- ------------------ ----------------- ');
writeln(' | 0-Ћђ…‹ | | 1-ђ…˜ЉЂ | | 2-€ѓђЋЉ€ | | 3-‡ЂЃђЂ’њ „…Ќњѓ€ | | 4-‚›•Ћ„ €‡ €ѓђ› | ');
writeln(' -------- --------- ---------- ------------------ ----------------- ');
writeln;
writeln( ' Ђ ' ,otv,' п зв®-в® Ґ ўЁ¦г');
writeln('--------------------------------------------------------------------------------');
goto start;
end;
if otv='2' then goto view;
if otv='3' then
begin
if not flag then {<--}
goto save
else
begin
writeln;
writeln(' •®зҐим ¤ҐмЈЁ § Ўа вм? ЌҐ в Є Ўлбва®. —в®Ўл ¤ҐмЈЁ § Ўа вм Ёе 㦮 § а Ў®в вм!');
writeln;
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
delay(65000); delay(65000);
goto start;
end;
end;
if otv='4' then goto exit;
if otv='0' then
begin
x:=WhereX;
y:=WhereY-1;
gotoXY(x,y);
writeln(' Ћђ…‹');
end;
if otv='1' then
begin
x:=WhereX;
y:=WhereY-1;
gotoXY(x,y);
writeln(' ђ…˜ЉЂ');
end;
money: begin
writeln;
Writeln(' ” ⥡п ',sum,' агЎ«Ґ©. ‘Є®«мЄ® бв ўЁим?');
writeln;
readln(stavka);
if stavka>sum then
begin
writeln;
writeln(' ’л зҐ бзЁв вм зв® «Ё Ґ 㬥Ґим, г вҐЎп Ґв в ЄЁе ¤ҐҐЈ!!!');
writeln('-----------------------------------------------------------------');
readln;
goto money;
end;
rez:=random(2);
if rez=1 then
begin
writeln;
writeln(' ‚лЇ « ђ…˜ЉЂ');
end;
if rez=0 then
begin
writeln;
writeln(' ‚лЇ « Ћђ…‹');
end;
tmp:=ord(otv)-48;
if {tmp=otv} rez=tmp then
begin
writeln;
writeln(' ”г и а ');
sum:=sum+stavka;
writeln;
writeln(' ‘зҐв: ',sum);
flag:=true; {<--}
writeln('-----------------------------------------------------------------');
end
else begin
writeln;
writeln( ' ”г б в ЄЁ¬ ЁЈа вм ¤ ¦Ґ Ґ ЁвҐаҐб®');
sum:=sum-stavka;
writeln;
writeln(' ‘зҐв: ',sum);
flag:=true; {<--}
writeln('------------------------------------------------------------------');
end;
end;
end;
if sum<=0 then
begin
writeln;
writeln(' ” вҐЎп § Є®зЁ«Ёбм Ў ЎЄЁ. Љ Є в®«мЄ® Ї®пўпвбп, § 室Ё');
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
delay(65000); delay(65000);
goto exit;
end;
view:
if count>0 then begin
writeln;
writeln(' -------------------------------------------');
writeln(' | €ѓђЋЉ':10, ' | „ҐмЈЁ':10,' |');
writeln(' |-------------------------------------------|');
end;
if count>0 then begin
i:=1;
while i<=count do begin
writeln(' | | |');
writeln(' | ',mas[i].name:10,' | ', mas[i].babki:10,' |');
writeln(' | | |');
inc(i);
end;
writeln(' -------------------------------------------');
end
else writeln(' ‘ЇЁб®Є Їгбв');
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
goto start;
view1:
if count>0 then begin
writeln;
writeln(' -------------------------------------------');
writeln(' | €ѓђЋЉ':10, ' | „ҐмЈЁ':10,' |');
writeln(' |-------------------------------------------|');
end;
if count>0 then begin
i:=1;
while i<=count do begin
writeln(' | | |');
writeln(' | ',mas[i].name:10,' | ', mas[i].babki:10,' |');
writeln(' | | |');
inc(i);
end;
writeln(' -------------------------------------------');
end
else writeln(' ‘ЇЁб®Є Їгбв');
goto start1;
save:
{writeln('Љ Є вҐЎп §®ўгв ?я'); readln(imya);}
b := False;
for i := 1 to count do begin
if imya = mas[i].name then begin
inc(mas[i].babki, sum);
rewrite(f);
for j := 1 to count do begin
writeln(f, mas[j].name);
writeln(f, mas[j].babki);
end;
close(f);
WRITELN;
writeln('Џа®©¤Ё ў Є ббг, в ¬ ⥡Ґ ўл¤ ¤гв вў®Ё зҐб⮧ а Ў®в лҐ ¤ҐмЈЁ');
WRITELN;
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
delay(65000); delay(65000);
b := true; break;
end;
end;
if not b then
if count<N then begin
inc(count);
mas[count].name:=imya;
mas[count].babki:=sum;
append(f);
writeln(f,mas[count].name);
writeln(f,mas[count].babki);
close(f);
writeln;
writeln('Џа®©¤Ё ў Є ббг, в ¬ ⥡Ґ ўл¤ ¤гв вў®Ё зҐб⮧ а Ў®в лҐ ¤ҐмЈЁ ');
writeln;
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
delay(65000); delay(65000);
end
else writeln('Нет места ');
goto start1;
exit: end.
Но так не работает. Кодировку не менял - она здесь не нужна.
Потом сделал так
Код
uses crt;
const N=1000;
label start1,save, view,view1, start, money, exit;
type
Dengi=record
name:string[9];
babki:word;
end;
var
b:boolean;
imya:string[15];
x,y,rez,flag:byte; {<--- Теперь flag byte}
tmp:word;
mas: array[1..N] of dengi;
otv,otvet:char;
i,j,sum,stavka,count:integer;
f:text;
begin {start1:}
textbackground(1);
textcolor(10);
clrscr;
start1:count:=0;
assign(f,'123.txt');
reset(f);
begin
while (not eof(f)) do
begin
inc(count);
readln(f,mas[count].name);
readln(f,mas[count].babki);
end;
end;
close(f);
flag:=0; {<--}
writeln;
writeln(' ------------- -------- --------------- ');
writeln(' |1-ЌЋ‚›‰ €ѓђЋЉ| |2-€ѓђЋЉ€| |3-‚›•Ћ„ €‡ €ѓђ›|');
writeln(' ------------- -------- --------------- ');
writeln;
otvet:=readkey;
if otvet='1' then begin
writeln;
writeln(' Љ Є вҐЎп §®ўгв ?я');
writeln;
readln(imya);
end;
if otvet='2' then goto view1;
if otvet='3' then goto exit;
randomize;
sum:=100;
writeln;
writeln( ' Ћђ…‹ €‹€ ђ…˜ЉЂ ');
while sum>0 do
begin
if sum>=1000 then
begin
writeln;
writeln(' Њ®Ґ Є §Ё® ®Ў Єа®вЁ«®бм, в Є зв® Ё¤Ё Є вл ®вбо¤ Ї®Є п вҐЎп Ґ гЎЁ«');
writeln;
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
delay(65000); delay(65000);
goto save;
end;
start:
writeln;
writeln(' -------- --------- ---------- ------------------ ----------------- ');
writeln('| 0-Ћђ…‹ | | 1-ђ…˜ЉЂ | | 2-€ѓђЋЉ€ | | 3-‡ЂЃђЂ’њ „…Ќњѓ€ | | 4-‚›•Ћ„ €‡ €ѓђ› | ');
writeln(' -------- --------- ---------- ------------------ ----------------- ');
writeln;
otv:=readkey;
if otv>'4' then
begin
writeln;
writeln(' ” ⥡п ᮢᥬ Ї«®е® б® §аҐЁҐ¬ ? Ќ ЇЁб ® ¦Ґ: ');
writeln;
writeln(' -------- --------- ---------- ------------------ ----------------- ');
writeln(' | 0-Ћђ…‹ | | 1-ђ…˜ЉЂ | | 2-€ѓђЋЉ€ | | 3-‡ЂЃђЂ’њ „…Ќњѓ€ | | 4-‚›•Ћ„ €‡ €ѓђ› | ');
writeln(' -------- --------- ---------- ------------------ ----------------- ');
writeln;
writeln( ' Ђ ' ,otv,' п зв®-в® Ґ ўЁ¦г');
writeln('--------------------------------------------------------------------------------');
goto start;
end;
if otv='2' then goto view;
if otv='3' then
begin
if flag=1 then {<--}
goto save
else
begin
writeln;
writeln(' •®зҐим ¤ҐмЈЁ § Ўа вм? ЌҐ в Є Ўлбва®. —в®Ўл ¤ҐмЈЁ § Ўа вм Ёе 㦮 § а Ў®в вм!');
writeln;
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
delay(65000); delay(65000);
goto start;
end;
end;
if otv='4' then goto exit;
if otv='0' then
begin
x:=WhereX;
y:=WhereY-1;
gotoXY(x,y);
writeln(' Ћђ…‹');
end;
if otv='1' then
begin
x:=WhereX;
y:=WhereY-1;
gotoXY(x,y);
writeln(' ђ…˜ЉЂ');
end;
money: begin
writeln;
Writeln(' ” ⥡п ',sum,' агЎ«Ґ©. ‘Є®«мЄ® бв ўЁим?');
writeln;
readln(stavka);
if stavka>sum then
begin
writeln;
writeln(' ’л зҐ бзЁв вм зв® «Ё Ґ 㬥Ґим, г вҐЎп Ґв в ЄЁе ¤ҐҐЈ!!!');
writeln('-----------------------------------------------------------------');
readln;
goto money;
end;
rez:=random(2);
if rez=1 then
begin
writeln;
writeln(' ‚лЇ « ђ…˜ЉЂ');
end;
if rez=0 then
begin
writeln;
writeln(' ‚лЇ « Ћђ…‹');
end;
tmp:=ord(otv)-48;
if {tmp=otv} rez=tmp then
begin
writeln;
writeln(' ”г и а ');
sum:=sum+stavka;
writeln;
writeln(' ‘зҐв: ',sum);
flag:=1; {<--}
writeln('-----------------------------------------------------------------');
end
else begin
writeln;
writeln( ' ”г б в ЄЁ¬ ЁЈа вм ¤ ¦Ґ Ґ ЁвҐаҐб®');
sum:=sum-stavka;
writeln;
writeln(' ‘зҐв: ',sum);
flag:=1; {<--}
writeln('------------------------------------------------------------------');
end;
end;
end;
if sum<=0 then
begin
writeln;
writeln(' ” вҐЎп § Є®зЁ«Ёбм Ў ЎЄЁ. Љ Є в®«мЄ® Ї®пўпвбп, § 室Ё');
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
delay(65000); delay(65000);
goto exit;
end;
view:
if count>0 then begin
writeln;
writeln(' -------------------------------------------');
writeln(' | €ѓђЋЉ':10, ' | „ҐмЈЁ':10,' |');
writeln(' |-------------------------------------------|');
end;
if count>0 then begin
i:=1;
while i<=count do begin
writeln(' | | |');
writeln(' | ',mas[i].name:10,' | ', mas[i].babki:10,' |');
writeln(' | | |');
inc(i);
end;
writeln(' -------------------------------------------');
end
else writeln(' ‘ЇЁб®Є Їгбв');
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
goto start;
view1:
if count>0 then begin
writeln;
writeln(' -------------------------------------------');
writeln(' | €ѓђЋЉ':10, ' | „ҐмЈЁ':10,' |');
writeln(' |-------------------------------------------|');
end;
if count>0 then begin
i:=1;
while i<=count do begin
writeln(' | | |');
writeln(' | ',mas[i].name:10,' | ', mas[i].babki:10,' |');
writeln(' | | |');
inc(i);
end;
writeln(' -------------------------------------------');
end
else writeln(' ‘ЇЁб®Є Їгбв');
goto start1;
save:
{writeln('Љ Є вҐЎп §®ўгв ?я'); readln(imya);}
b := False;
for i := 1 to count do begin
if imya = mas[i].name then begin
inc(mas[i].babki, sum);
rewrite(f);
for j := 1 to count do begin
writeln(f, mas[j].name);
writeln(f, mas[j].babki);
end;
close(f);
WRITELN;
writeln('Џа®©¤Ё ў Є ббг, в ¬ ⥡Ґ ўл¤ ¤гв вў®Ё зҐб⮧ а Ў®в лҐ ¤ҐмЈЁ');
WRITELN;
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
delay(65000); delay(65000);
b := true; break;
end;
end;
if not b then
if count<N then begin
inc(count);
mas[count].name:=imya;
mas[count].babki:=sum;
append(f);
writeln(f,mas[count].name);
writeln(f,mas[count].babki);
close(f);
writeln;
writeln('Џа®©¤Ё ў Є ббг, в ¬ ⥡Ґ ўл¤ ¤гв вў®Ё зҐб⮧ а Ў®в лҐ ¤ҐмЈЁ ');
writeln;
delay(65000); delay(65000); delay(65000); delay(65000); delay(65000);
delay(65000); delay(65000);
end
else writeln('Нет места ');
goto start1;
exit: end.
и заработало. Почему так
?