|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
04.06.2008, 21:00 | #1 |
Пользователь
Регистрация: 09.02.2008
Сообщений: 38
|
ПАСКАЛЬ задача
дан файл, в котором обозначенны самолёты.
Пример обозначения самолёта В-3726 reis1763 ТУ-154M 17:35 бортовой номер марка время входа номер рейса самолета Таких обозначений в файле может быть N-ое колличество Сделать так чтобы программа в Паскале отсортировала все записи с использованием индексной сортировки, методом пузырька в порядке возростания номеров рейса. Прога работает, токо в ней при проверке корректности значений в файле используется метод посимвольной проверки, тоесть например проверяя бортовой номер В-3726 проверяешь отдельно "В" отдельно "-" и каждую цифру поотдельности, а надо чтобы проверялась "В-" и "3726" ьам надо как-то через функцию объединения "Val(...)" |
04.06.2008, 21:00 | #2 |
Пользователь
Регистрация: 09.02.2008
Сообщений: 38
|
Могу выложить то что я нацарапал
|
04.06.2008, 21:07 | #3 |
Пользователь
Регистрация: 09.02.2008
Сообщений: 38
|
Program lad;
Uses crt; const pyt='LAB6.pas'; pyt2='LAB6.pas'; Kol=10; TtimeH1=[#48,#49,#50]; TtimeH2=[#48..#57]; TtimeH12=[#48..#51]; TtimeM1=[#48..#53]; TtimeM2=[#48..#57]; TtimeR=[#58]; Tnumber1=[#65..#90,#128..#159]; Tnumber2=[#45]; Tnumber3=[#48..#57]; Treis=[#48..#57]; Type Max=record time:string[5]; Marka:string[7]; Number:string[6]; Reis:string[4]; Ind:integer; end; Indeks=record reis:string[4]; ind:integer; end; Masind=array [1..kol] of indeks; Mas=array [1..kol] of Max; Procedure readtabl (var table1:Mas; var size1:integer; var errcode:integer; Var MInd:MasInd); Var f1:text; i:integer; blank: char; begin Assign (f1,pyt); Reset (f1); i:=0; repeat i:=i+1; if not (eof(f1)) and (i=kol) then begin errcode:=50; break; end; With table1 [i] do begin readln (f1,number,blank,reis,blank,marka,b lank,time); ind:=i; end; size1:=i; Until (eof(f1)); Close (f1); end; Procedure control (table1:Mas; size1:integer; var errcode:integer; var errstr:integer); Var i,j:integer; err:boolean; b2:string; Begin Err:=False; For i:=1 to size1 do with Table1[i] do Begin If not (time[1] in TtimeH1) then Begin Errstr:=i; errcode:=1; break; end; If not (time[2] in TtimeH2) then Begin Errstr:=i; errcode:=2; break; end; If time[1]=#50 then If not (time[2] in TtimeH12) then Begin Errstr:=i; errcode:=3; break; end; If not (time[3] in TtimeR) then Begin Errstr:=i; errcode:=4; break; end; If not (time[4] in TtimeM1) then Begin Errstr:=i; errcode:=5; break; end; If not (time[5] in TtimeM2) then Begin Errstr:=i; errcode:=6; break; end; If not (Number[1] in Tnumber1) then Begin Errstr:=i; errcode:=7; break; end; If not (Number[2] in Tnumber2) then Begin Errstr:=i; errcode:=7; break; end; If not (Number[3] in Tnumber3) then Begin Errstr:=i; errcode:=7; break; end; If not (Number[4] in Tnumber3) then Begin Errstr:=i; errcode:=7; break; end; If not (Number[5] in Tnumber3) then Begin Errstr:=i; errcode:=7; break; end; If not (Number[6] in Tnumber3) then Begin Errstr:=i; errcode:=7; break; end; If not (Reis[1] in Treis) then Begin Errstr:=i; errcode:=8; break; end; If not (Reis[2] in Treis) then Begin Errstr:=i; errcode:=8; break; end; If not (Reis[3] in Treis) then Begin Errstr:=i; errcode:=8; break; end; If not (Reis[4] in Treis) then Begin Errstr:=i; errcode:=8; break; end; For j:=1 to size1 do begin if i=j then continue; if number=Table1[j].number then begin errcode:=20; err:=true; errstr:=i; break; end; For j:=1 to size1 do begin if i=j then continue; if marka=Table1[j].marka then begin errcode:=21; err:=true; errstr:=i; break; end; end; If err then break; end; end; end; Procedure Viverr (errcode:integer; errstr:integer); Begin Case errcode of 0:exit; |
04.06.2008, 21:08 | #4 |
Пользователь
Регистрация: 09.02.2008
Сообщений: 38
|
1:writeln ('Nevernoe vremia vxoda (chasi) v zony v zapisi #',errstr);
2:writeln ('Nevernoe vremia vxoda (Chasi) v zony v zapisi #',errstr); 3:writeln ('Nevernoe vremia vxoda (Minyti) v zony v zapisi #',errstr); 4:writeln ('Nevernoe vremia vxoda (Minyti) v zony v zapisi #',errstr); 5:writeln ('Nevernoe vremia vxoda (format) v zony v zapisi #',errstr); 6:writeln ('Nevernoe vremia vxoda (24 format) v zony v zapisi #',errstr); 7:writeln ('Nevernij bortovoi nomer v zapisi #',errstr); 8:writeln ('Reis doljen bit 4-ex znachnim chislom #',errstr); 20:writeln ('Nomera ne ynikalni oshibka v zapisi #',errstr); 21:writeln ('Nomera ne ynikalni oshibka v zapisi #',errstr); 50:writeln ('Oshibka zapisei bolshe chem ',kol); end; end; Procedure PrintTabl (Table1:Mas; Size1:integer; MInd:MasInd); Var i:integer; Begin Write (#201,#205,#205,#205,#205,#203,#205 ,#205,#205,#205,#205,#205,#203,#205 ,#205,#205,#205,#205,#205,#205,#203 ); Writeln (#205,#205,#205,#205,#205,#205,#205 ,#203,#205,#205,#205,#205,#205,#187 ); Writeln (#186,' # ',#186,'Number',#186,' Reis',#186,' Marka ',#186,'time ',#186); For i:=1 to size1 do Begin Write (#204,#205,#205,#205,#205,#206,#205 ,#205,#205,#205,#205,#205,#206,#205 ,#205,#205,#205,#205,#205,#205,#206 ); Writeln (#205,#205,#205,#205,#205,#205,#205 ,#206,#205,#205,#205,#205,#205,#185 ); Write (#186,i:3,')',#186); With Table1 [Mind[i].ind] do Writeln (Number,#186,' ',reis,#186,Marka,#186,time,#186); end; Write (#200,#205,#205,#205,#205,#202,#205 ,#205,#205,#205,#205,#205,#202,#205 ,#205,#205,#205,#205,#205,#205,#202 ); Writeln (#205,#205,#205,#205,#205,#205,#205 ,#202,#205,#205,#205,#205,#205,#188 ); end; Procedure SortTable (var Table1:Mas; Size1:integer; var MInd:MasInd); Var i,j:integer; Buff:indeks; Begin For i:=1 to size1 do Begin MInd[i].reis:=Table1[i].reis; MInd[i].ind:=Table1[i].ind; end; For i:=1 to (size1-1) do For j:=1 to (size1-i) do If Mind[j].reis>Mind[j+1].reis then Begin buff:=Mind[j]; Mind[j]:=Mind[j+1]; Mind[j+1]:=buff; end; end; VAR MInd:MasInd; Table:Mas; f:text; size:integer; Errcode:integer; Errstr:integer; BEGIN Clrscr; ReadTabl (Table,size,errcode,MInd); Viverr (errcode,errstr); If (errcode=0) then Begin Control (Table,size,errcode,errstr); Viverr (errcode,errstr); If (errcode=0) then Begin SortTable (Table,size,MInd); Writeln ('Danie posle sortirovri'); PrintTabl (Table,size,MInd); end; end; readln; END. |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Задача Паскаль help plz | menlo | Помощь студентам | 1 | 15.12.2007 17:40 |
Паскаль. задача с олимпиады | SoulFlyMF | Помощь студентам | 2 | 13.11.2007 20:52 |
Паскаль. задача с помощью FOR TO DO | Маринуська | Помощь студентам | 7 | 29.10.2007 18:49 |
Паскаль. задача на массив | narkozz | Паскаль, Turbo Pascal, PascalABC.NET | 3 | 23.05.2007 20:48 |
Задача с матрицей, Паскаль | Integra | Помощь студентам | 1 | 25.04.2007 16:14 |