Advertisement
Josif_tepe

Untitled

Jan 16th, 2024
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.12 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4. int main() {
  5.     char s[1000];
  6.     fgets(s, 500, stdin);
  7.     int brojac = 0;
  8.     int najdolg_termin = 0;
  9.     int h, sec;
  10.     for(int i = 0; i < strlen(s); i++) {
  11.         if(s[i] == ':') {
  12.             if(isdigit(s[i - 1]) && isdigit(s[i - 2]) && isdigit(s[i + 1]) && isdigit(s[i + 2])) {
  13.                 brojac++;
  14.                 int hours = (s[i - 2] - '0') * 10 + (s[i - 1] - '0');
  15.                 int minutes = (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
  16.  
  17.                 if(najdolg_termin < hours * 60 + minutes) {
  18.                     najdolg_termin = hours * 60 + minutes;
  19.                     h = hours;
  20.                     sec = minutes;
  21.                 }
  22.  
  23.             }
  24.         }
  25.     }
  26.     printf("Vo tekstot ima navedneo %d vremenski termini. Najdocniot termin e %d:%d\n", brojac, h, sec);
  27.    
  28.     return 0;
  29. }
  30.  
  31.  
  32. /*
  33. Predavanjata po PiA pochnuvaat vo 08:00 chasot, a auditoriskite vezhbi pochnuvaat vo 12:00 chasot. Za laboratoriski vezhbi na raspolaganje ima tri termini: prviot od 14:00 vo 322A, vtoriot od 15:30 vo 322A i tretiot od 18:30 vo 322A
  34. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement