1. Заголовок темы должен быть информативным. В противном случае тема удаляется ... 2. Все тексты программ должны помещаться в теги [code=pas] ... [/code], либо быть опубликованы на нашем PasteBin в режиме вечного хранения. 3. Прежде чем задавать вопрос, см. "FAQ", если там не нашли ответа, воспользуйтесь ПОИСКОМ, возможно такую задачу уже решали! 4. Не предлагайте свои решения на других языках, кроме Паскаля (исключение - только с согласия модератора). 5. НЕ используйте форум для личного общения, все что не относится к обсуждению темы - на PM! 6. Одна тема - один вопрос (задача) 7.Проверяйте программы перед тем, как разместить их на форуме!!! 8.Спрашивайте и отвечайте четко и по существу!!!
Создать запись. Создать файл записей. Организовать хранение записей в файле и работу с файлом и записями. Создать меню со следующими пунктами: 1.Добавить элемент в конец; 2.Удалить элемент по порядковому номеру; 3.Вывести элементы на экран ввиде таблицы; 4.Найти элемент по двум полям на выбор; 5.Редактировать элемент; 6.Выход. Описать структуру "Город". У города есть название,количество жителей,статус,мэр.
var f:file of city; f1,f2:string; p:longint; n,i,j,c,x,x1,x2,x3,x4,x5,a:integer; City_:array[1..10] of city; command:byte; d,cap:char; stop,ex:boolean;
begin n:=0;
assign(f,'genius.dat');
{$I-} Reset(f); {$I+}
if ioresult<>0 then
begin writeln('To creat the file?'); writeln('1- Yes'); writeln('2-No'); readln(a); if a=1 then rewrite(f) else writeln('You must to creat the file!');end;
n:=filesize(f);
repeat
TextBackGround(9); ClrScr; TextColor(12); GotoXY(20,4); writeln('|--------------------[ MENU ]-----------------|'); GotoXY(20,5); writeln('| 1 - to add new the City |'); GotoXY(20,6); writeln('| 2 - to delete the City |'); GotoXY(20,7); writeln('| 3 - to remove the list on monitor |'); GotoXY(20,8); writeln('| 4 - to find the City |'); GotoXY(20,9); writeln('| 5 - to edit the City |'); GotoXY(20,10);writeln('| 6 - to escape |'); GotoXY(20,11);writeln('|---------------------------------------------|'); GotoXY(20,16); TextBackGround(9); TextColor(15); write('Enter 1, 2, 3 ,4 ,5 or 6 : '); Readln(command); writeln;
case command of 1:
begin
writeln('Add new City?(Y)\(N)'); read(d); if d='y' then
begin
n:=n+1;
writeln('Enter the name'); readln; readln(city_[n].name);
writeln('Status of capital:(Y)\(N)'); readln(cap); if cap='y' then city_[n].capital:='*Capital*'; if cap='n' then city_[n].capital:='*Settlement*';
if p>=1000000 then city_[n].stat:='*****'; if (p>=500000) and (p<1000000) then city_[n].stat:='****'; if (p>=100000) and (p<500000) then city_[n].stat:='***'; if (p>=50000) and (p<100000) then city_[n].stat:='**'; if (p<50000) then city_[n].stat:='*';
3: begin seek(f,0); read(f,city_[n]); x1:=19; x2:=0;
write(l1); for x:=1 to 14 do write(l5); write(l11); for x:=1 to 14 do write(l5); write(l11); for x:=1 to 14 do write(l5); write(l11); for x:=1 to 14 do write(l5); write(l11); for x:=1 to 14 do write(l5); writeln(l3); gotoxy(1,19); write(l6);write('"Name"'); gotoxy(16,19); write(l6);write('"Population"'); gotoxy(31,19); write(l6);write('"Mayor"'); gotoxy(46,19); write(l6);write('"Capital"'); gotoxy(61,19); write(l6);write('"Status"'); gotoxy(76,19); writeln(l6); x3:=(n+1)*2; for x4:=2 to x3-1 do begin x5:=x4 mod 2; x1:=x1+1; if x5=0 then begin write(l8); for x:=1 to 14 do write(l5); write(l7); for x:=1 to 14 do write(l5); write(l7); for x:=1 to 14 do write(l5); write(l7); for x:=1 to 14 do write(l5); write(l7); for x:=1 to 14 do write(l5); writeln(l9); end else begin
x2:=x2+1; gotoxy(1,x1); write(l6); write(city_[x2].name); gotoxy(16,x1); write(l6); write(city_[x2].population); gotoxy(31,x1); write(l6); write(city_[x2].mayor); gotoxy(46,x1); write(l6); write(city_[x2].capital); gotoxy(61,x1); write(l6); write(city_[x2].stat); gotoxy(76,x1); writeln(l6); end; end; write(l2); for x:=1 to 14 do write(l5); write(l10); for x:=1 to 14 do write(l5); write(l10); for x:=1 to 14 do write(l5); write(l10); for x:=1 to 14 do write(l5); write(l10); for x:=1 to 14 do write(l5); writeln(l4); readln; end;
4: begin writeln('"Search"'); writeln; writeln('Please,enter the name:'); readln(f1); writeln('Please,enter the mayor:'); readln(f2); i:=0; stop:=true; repeat seek(f,i); read(f,city_[i+1]);
if (city_[i+1].name=f1) and (city_[i+1].mayor=f2) then begin seek(f,i);
writeln('Status of capital:(Y)\(N)'); readln(cap); if cap='y' then city_[i].capital:='***Capital***'; if cap='n' then city_[i].capital:='*Settlement*';
if p>=1000000 then city_[i].stat:='*****'; if (p>=500000) and (p<1000000) then city_[i].stat:='****'; if (p>=100000) and (p<500000) then city_[i].stat:='***'; if (p>=50000) and (p<100000) then city_[i].stat:='**'; if (p<50000) then city_[i].stat:='*';
write(f,city_[i]); writeln;
end;
6: begin ex:=true; end; end; until ex; close(f);
end.
Всё работает,кроме 3 пункта. А именно: после закрытия файла таблица не выводит имееющиеся поля. Объясните в чем косяк,пожалуйста!