这是一道模拟题,可以先把各个相交的点求出来,然后再一个个去判是否在给的区间里 程序代码: #include <iostream> #include <cstdio> using namespace std; typedef struct{ int Houre, Minute; }pill; pill nInitial, nFinal; int nPass[] = {65, 130, 196, 262, 327, 392, 458, 523, 589, 654, 720}; void swap(int &a, int &b) { int c = a; a = b; b = c; } int main() { int pass, flag; int front, end; //freopen("input.txt", "r", stdin); printf("Program 3 by team X/n"); printf("Initial time Final time Passes/n"); while(scanf("%d %d %d %d", &nInitial.Houre, &nInitial.Minute, &nFinal.Houre, &nFinal.Minute) == 4){ printf(" %02d:%02d", nInitial.Houre, nInitial.Minute); printf(" %02d:%02d", nFinal.Houre, nFinal.Minute); pass = flag = 0; front = nInitial.Houre * 60 + nInitial.Minute; end = nFinal.Houre * 60 + nFinal.Minute; if(front > end){ flag = 1; swap(front, end); } for(int i = 0; i < 11; i++){ if(nPass[i] >= front && nPass[i] < end) pass++; } flag ? printf("%8d/n", 11 - pass) : printf("%8d/n", pass); } printf("End of program 3 by team X/n"); return 0; }