Code
# Include <stdio. h> # include <string. h ># include <algorithm> using namespace STD; struct time {char sta [5], end [5];} Times [110]; bool CMP (time g, time h) {return strcmp (G. end, H. end) <0;} Char E [5], F [5], K [5]; int main () {int N; int A, B, C, D; int I, j; int sum; while (scanf ("% d", & N )! = EOF) {for (I = 0; I <n; I ++) {scanf ("% d % * C % d", & A, & B, & C, & D ); E [0] = A/10 + '0'; E [1] = A % 10 + '0'; E [2] = B/10 + '0 '; E [3] = B % 10 + '0'; F [0] = C/10 + '0'; F [1] = C % 10 + '0 '; f [2] = D/10 + '0'; F [3] = D % 10 + '0'; If (strcmp (e, f) <0) {strcpy (Times [I]. STA, e); strcpy (Times [I]. end, f);} else {strcpy (Times [I]. STA, f); strcpy (Times [I]. end, e) ;}/// int type storage can be directly used here/* scanf ("% d % C % d", & B1, & C, & B2, & C, & E1, & C, & E2); t [I]. B = b1 * 100 + B2; t [I]. E = e1 * 100 + E2; // here, the child's start and end time are converted from two variables: hour and minute into a convenient operation if (T [I]. b> T [I]. e) Swap (T [I]. b, T [I]. e); */sort (times, times + N, CMP); sum = 1; strcpy (K, times [0]. end); for (I = 1; I <n; I ++) {If (strcmp (Times [I]. STA, k)> 0) {sum ++; strcpy (K, times [I]. end); // select the least public vertex among multiple intervals} printf ("% d \ n", sum);} return 0 ;}