, .. - .
READ (READLN) , WRITE (WRITELN), , .
1.1. , b, X. , , : WRITE, , ( a b X), READLN(a,b,X), , . :
WRITE ( : b ); { }
READLN (a,b,X); { }
, . - ( ), . , Write a b , . - , . , .
? READ (READLN) . , , , , . . . . .
. READLN . , . ( Enter) . 1 N = Length (< >), Length - . ( Copy) ( Pos) , , , , . , , Val .
|
|
, .
1.2. .
(0 - 24).
.
Program Wwod_hours1;
Label 1,2;
Var
hou,hours:string[3]; err,er,i,h,hour_istina:integer;
BEGIN
2: er:=0;
Write( 0..24 );
Readln(hours); { }
hou:= ;
For i:= 1 to length(hours) do { }
Begin
If pos((copy(hours,i,1)),0123456789') = 0 Then
{ : - }
{ Pos - }
{ }
{ , 0123456789 }
Begin
er:=1; { }
Goto 1;
End
Else
Begin
hou:= hou + copy(hours,i,1);
Writeln(hou);
End;
1: End;
Val(hou,hour_istina,err); {Val - }
if er=1 Then
Begin
Writeln( ! ! );
Goto 2;
End
Else If hour_istina <= 24 { }
Then
Writeln(ac ,hour_istina)
Else
Begin
Writeln(ac > 24 , !);
Goto 2 { }
End
END.
, , , , , (, :7:2).
(. 1.3) ReadKey Crt ( . ), . , , ReadKey. . , , , . , . , ( ). , Enter Val.
1.3. .
(0 - 24).
ReadKey.
Program Wwod_hours2;
Uses Crt; { }
Label 2;
Var
ho:Char;
hours:String[2];
err,i,hour_istina:lnteger;
BEGIN
2: Write ( 0..24 );
hours:=;i:=0;
{ }
Repeat ho:= ReadKey; { }
If (ho > #47) And (ho < #58) Then { 0 9}
Begin
Write(ho); { (-)}
i:=i+1; { }
hours:= hours + ho; { }
End
Else If ho <> #13 Then {#13 - Enter}
|
|
Write(#7); { . }
Until (ho = #13) Or (i = 2); { , }
{ Enter = 2}
Writeln;
Val(hours,hour_istina,err); { hours }
If hour_istina <= 24 { }
Then Writeln( ,hour_istina)
Else Begin Writeln( > 24 . !);
Goto 2
End
END.
ReadKey KeyPressed. , ReadKey, , .. . , - (. 1.3).
KeyPressed True, (.. - ), False, . :
If KeyPressed then <> else <>;
. KeyPressed ReadKey, .
. , :
Repeat ho:= ReadKey; { }
If (ho > #47) And (ho < #58) Or { ...}
(ho=#46) And Perv Or {...- ...}
(ho = #45) And (i =0) Then {... 1- ...}
Begin
i:= i+1;
hours:= hours + ho; {... hours}
If ho = #46 Then Perv:= False; { }
Write(ho) { }
End;
- .