Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 18.05.2011, 21:00   #1
Arabic_Coffee
 
Регистрация: 11.05.2011
Сообщений: 6
По умолчанию Сортировка паскаль

Помогите пожалуйста отсортировать записи в файле и то что получится вывести на экран...
Вот сам код:
Код:
program kurs;
uses crt;
TYPE train=record
     naz:string[17];
     nom:Word;
     tim:string[13];
end;
Const
 Nmax=20;
var
 mas:array[1..Nmax] of train;
 i:integer;
 otv:char;
 filee:text;
 s:String;
 N:Byte;

procedure file_form;
begin
 ReWrite(filee);
 writeln(filee,'---------------------------------------------');
 writeln(filee,'|      punkt      |   nomer   |    time     |');
 writeln(filee,'---------------------------------------------');
 Close(filee);
end;

procedure file_read(var Nf:Byte);
var stf:string[11]; chf:Char; Code:Word;
begin
 ReSet(filee);
 For i:=1 to 3 do
  ReadLn(filee);
 Nf:=0;
 While not EoF(filee) do
  begin
   Inc(Nf);
   ReadLn(filee,chf,Mas[Nf].naz,chf,stf,chf,Mas[Nf].tim);
   Val(stf,Mas[Nf].nom,Code);
  end;
 Close(filee);
end;

procedure search;
var t,j:Word; k:Integer; b:boolean;
begin
 clrscr;
 Repeat
  write('Enter the number of train ');
  readln(t);
  j:=0;
  b:=false;
  Repeat
   Inc(j);
   If Mas[j].nom=t then b:=true;
  Until b;
  If b then
   begin
    ReSet(filee);
    For k:=1 to 3 do
     begin
      ReadLn(filee,s);
      WriteLn(s);
     end;
    For k:=1 to j-1 do
     ReadLn(filee);
    ReadLn(filee,s);
    WriteLn(s);
   end
  else
   Writeln('The number of train is wrong!');
 Until b;
 Close(filee);
end;

procedure vvodd(var Nv:Byte);
var i:integer; otv:Char;
begin
 Append(filee);
 Repeat
  Write('Next train (Y/N)? ');
  ReadLn(otv);
   If (otv='Y') or (otv='y') then
    begin
     Inc(Nv);
     Write(filee,'|');
     WriteLn('Enter punkt: ');
     ReadLn(s);
     For i:=1 to 17-Length(s) do
      Write(filee,' ');
     Write(filee,s);
     Write(filee,'|');
     Mas[Nv].naz:=Mas[Nv].naz+s;
     WriteLn('Enter nomer: ');
     ReadLn(mas[Nv].nom);
     Write(filee,mas[Nv].nom:11);
     Write(filee,'|');
     WriteLn('Enter time (HH:MM): ');
     ReadLn(s);
     For i:=1 to 13-Length(s) do
      Write(filee,' ');
     Write(filee,s);
     WriteLn(filee,'|');
    end;
 Until (otv='N') or (otv='n');
 close(filee);
end;

procedure vivod;
var st:String;
begin
 Reset(filee);
 while not eof(filee) do
  begin
   readln(filee,st);
   writeln(st);
  end;
 close(filee);
 readln;
end;

begin
 {$I-}
 clrscr;
 Assign(filee,'Kurs.txt');
 ReSet(filee);
 If IOResult<>0 then
  begin
   file_form;
   vvodd(N);
  end;
 file_read(N);
 while true do
  begin
   clrscr;
   writeln('Menu:');
   writeln('1 Vvod information');
   writeln('2 Vivod information');
   writeln('3 Poisk information');
   writeln('4 Exit');
   readln(otv);
   case otv of
   '1':begin vvodd(N); file_read(N); end;
   '2':vivod;
   '3':search;
   '4':exit;
   end;
   write('Continue [y/n]? ');
   readln(otv);
   if (otv='N') or (otv='n') then exit;
  end;
end.
Arabic_Coffee вне форума Ответить с цитированием
Старый 18.05.2011, 21:03   #2
Arabic_Coffee
 
Регистрация: 11.05.2011
Сообщений: 6
По умолчанию

Отсортировать по номеру надо
Arabic_Coffee вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Паскаль. Сортировка recerpascal Помощь студентам 3 20.04.2011 00:42
Сортировка, Паскаль masterlomaster Помощь студентам 1 16.12.2010 11:16
паскаль,одномерный массив,сортировка вставка,сортировка убывания,от максимального до конца немозг Помощь студентам 11 06.02.2010 21:57
Паскаль. Сортировка в Паскале. FeelTheSkill Помощь студентам 4 10.02.2007 07:54