Task:
The current reading of the electronic clock: m hours (0 <= m <= 23), n min (0 <= n <= 59), k sec (0 <= k <= 59). What time will the clock be shown after p h d min rc?
(The problem on the topic "Linear algorithms", but I, trying to solve it, exceeded the limit).
My trial:
#include <stdio.h> #include <conio.h> int main() { int h, m, s; long int h_, m_, s_; h=23; m=59; s=59; printf("Текущее время: %d : %d : %d",h,m,s); printf("\nВведите поправку: часы, затем минуты и секунды"); scanf("%ld%ld%ld",&h_,&m_,&s_); if ( h+h_>=0 && h+h_<=23 ) printf ("Новое значение часов: %d", h+h_ ) if ( h+h_<=23+24 && h+h_>=0+24 ) printf("Новое значение часов: %d", h+h_-24); if ( h+h_>=24+24 && h+h_<=47+24) printf("Новое значение часов: %d", h+h_-24*2); ... ... // некий цикл
h:m:s. Or carefully implement the summation with the transfer, and first seconds, then minutes and only the last hour are summed up first. - AnT<time.h>? - Vitaly Shebanits[циклы]? Why is this tag on the question? And why in the code there is a comment about "a certain cycle"? Where did the cycle come from? - AnT