![]() |
|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
![]() |
|
Опции темы | Поиск в этой теме |
![]() |
#1 |
Пользователь
Регистрация: 24.12.2008
Сообщений: 11
|
![]()
program praktika2;
uses crt; type zap1=record nr:string[25]; m:string[25]; ms:string[10]; end; type zap2=record s:string[25]; end; type files=file of zap1; type files2=file of zap2; type mas=array[1..100] of zap2; Var x:zap1; f2:files; v,v1:byte; k:mas; procedure sozd_file(Var f:files); Var i,v:byte; Begin clrscr; assign(f,'Files_zap'); rewrite(f); i:=1;v:=0; while not eof do begin clrscr; readln; writeln('номер рейса(',i,'):'); read(x.nr); readln; writeln('маршрут(',i,'):'); read(x.m); readln; writeln('Марка самолета(',i,'):'); read(x.ms); k[i].s:=x.ms; readln; write(f,x); writeln('Вы хотите завершить ввод(если да,то нажмите CTRL+Z,иначе ENTER)'); readln; i:=i+1; end; close(f); close(input); reset(input); readkey; end; procedure prosm(var f:files); Var x:zap1; Begin clrscr; assign(f,'Files_zap'); {$i-}reset(f);{$i+} writeln; if ioresult <> 0 then write('Файл не существует!'); writeln('+-------------------------------------------------------------+'); writeln('I','номер рейса':15,'I','Маршрут':15,'I','Мар ка самолета':11,'I'); writeln('+-------------------------------------------------------------+'); while not eof(f) do begin with x do begin read(f,x); write('I');write(x.nr:15); write(' I',x.m:15); write('I',x.ms:11); end; writeln; end; writeln('+-------------------------------------------------------------+'); close(f); close(input); reset(input); readkey; end; procedure sort(var f: files); var m,n,z:longint; i,flag:integer; x,x1:zap1; begin reset(f); assign(f,'Files_zap'); reset(f); z:=filesize(f); m:=0; repeat flag:=0; for n:=0 to (z-2-m) do begin seek(f,n); read(f,x); seek(f,n+1); read(f,x1); if x.ms>x1.ms then begin Seek(f,n); write(f,x1); write(f,x); flag:=1; end; end; m:=m+1; until (m>z-1) or (flag=0); close(f); close(input); reset(input); readkey; end; procedure Copy(Var f,fd:files2); var x:zap2; begin assign(f,'praktika'); assign(fd,'praktika2'); reset(f); rewrite(fd); while not eof(f) do begin read(f,x); write(fd,x); end; close(fd); close(f); close(input); reset(input); readkey; end; reset(f1); writeln('+-------------------------------------------+'); writeln('I Марка самолета I Количество рейсов I'); writeln('+-------------------------------------------+'); reset(f1); while not eof(f1) do begin read(f1,x2); with x2 do begin write('I');write(x2.s:10); write(' I'); write(x2.kpb:10);write(' I'); end; writeln; end; writeln('I************************* ******************I'); writeln('IВсего: ',l:4:1,' I'); writeln('+-------------------------------------------+'); close(f); close(f1); close(input); reset(input); end; Begin clrscr; checkeof:=true; assign(f2,'Files_zap'); repeat writeln(' Меню '); writeln('1.Создание '); writeln('2.Просмотр '); writeln('3.Сортировка '); writeln('5.Выход '); repeat readln(v); until (v>=1)and(v<=5); if v=1 then sozd_file(f2); if v=2 then prosm(f2); if v=3 then begin clrscr;sort(f2); end; if v=4 then begin clrscr;uv(f2); end; if v=5 then v1:=4; if (v>=1) and (v<5) then begin writeln; writeln('Для возврата в меню нажмите 1'); writeln('Для выхода из программы нажмите 2'); readln(v1); end; if v1=1 then v:=1 else v:=5; clrscr; until(v=5); end. надо чтобы он сортировал в 1 таблице по Марке самолёта..а во 2 определить кол-во рейсов по маркам самолёта. Последний раз редактировалось DIzza; 15.06.2009 в 23:46. |
![]() |
![]() |
![]() |
#2 |
Delphi Warrior
Старожил
Регистрация: 15.08.2008
Сообщений: 2,502
|
![]()
А что собственно не работает????
Он неправильно сортирует??? Или выдаёт ошибку???
Mess with the best, die like the rest.
![]() Лабораторные, курсовые на Delphi\Pascal\C++ ya.flex-freelance@yandex.ru Icq - 636-954-303 |
![]() |
![]() |
![]() |
#3 |
Пользователь
Регистрация: 24.12.2008
Сообщений: 11
|
![]()
он вообще не сортирует...практически всё перепробовал..
|
![]() |
![]() |
![]() |
#4 |
Delphi Warrior
Старожил
Регистрация: 15.08.2008
Сообщений: 2,502
|
![]()
Используй типизированные массивы!! В них производи сортировку!! А потом пиши в заного в файл!!!
Mess with the best, die like the rest.
![]() Лабораторные, курсовые на Delphi\Pascal\C++ ya.flex-freelance@yandex.ru Icq - 636-954-303 |
![]() |
![]() |
![]() |
![]() |
||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Помогите с сортировкой в C++. | Vollmond36 | Помощь студентам | 1 | 02.12.2008 23:06 |
Помогите с сортировкой. | Dissonance | БД в Delphi | 14 | 05.06.2008 15:35 |
Помогите с сортировкой | AHTOXA | Общие вопросы Delphi | 2 | 08.06.2007 12:46 |
Помогите с сортировкой | radist | Паскаль, Turbo Pascal, PascalABC.NET | 5 | 23.04.2007 12:50 |