Vladimir_S |
13.01.2018 10:07 |
Всё, чем могу помочь — написать решение на Паскале. Эту программу можно взять за основу, а дальше резвиться с Делфи-формами.
Код:
Var
S1,S2,h,m,s,h_s,m_s,s_s:String;
Act:Char;
T,Time1,Time2,Time3,Day:LongInt;
Code:Word;
h_b,m_b,s_b:Byte;
b1,b2,b3,b4,b5,b6,b7:Boolean;
Begin
Day:=24*3600;
Repeat
b1:=True; b2:=True; b3:=True; b4:=True; b5:=True; b6:=True; b7:=True;
Write('Enter the first time (hh:mm:ss) ');
Readln(S1);
Write('Enter the action ("+","-") ');
Readln(Act);
if (Act<>'+') and (Act<>'-') then b7:=False;
Write('Enter the second time (hh:mm:ss) ');
Readln(S2);
h_s:=S1[1]+S1[2];
m_s:=S1[4]+S1[5];
s_s:=S1[7]+S1[8];
Val(h_s,T,Code);
if T>23 then b1:=False;
Time1:=T*3600;
Val(m_s,T,Code);
if T>59 then b2:=False;
Time1:=Time1+T*60;
Val(s_s,T,Code);
Time1:=Time1+T;
if T>59 then b3:=False;
h_s:=S2[1]+S2[2];
m_s:=S2[4]+S2[5];
s_s:=S2[7]+S2[8];
Val(h_s,T,Code);
if T>23 then b4:=False;
Time2:=T*3600;
Val(m_s,T,Code);
if T>59 then b5:=False;
Time2:=Time2+T*60;
Val(s_s,T,Code);
if T>59 then b6:=False;
Time2:=Time2+T;
if Not(b1) or Not(b2) or Not(b3) or Not(b4) or Not(b5) or Not(b6) or Not(b7)
then
Writeln('Incorrect!!!');
Until b1 and b2 and b3 and b4 and b5 and b6 and b7;
if Act='+' then Time3:=Time1+Time2 else Time3:=Time1-Time2;
if Time3>Day then Time3:=Time3-Day;
if Time3<0 then Time3:=Day+Time3;
Write('Result: ');
h_b:=Time3 div 3600;
Time3:=Time3 mod 3600;
if h_b<10 then write('0',h_b) else write(h_b);
write(':');
m_b:=Time3 div 60;
s_b:=Time3 mod 60;
if m_b<10 then write('0',m_b) else write(m_b);
write(':');
if s_b<10 then write('0',s_b) else write(s_b);
Readln
End.
|