这道题在做的时候,注意下格式就没问题啦!
现在将我的代码给大家分享一下:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
// freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
int t,n;
int h1,h2,m1,m2;
int i,j;
int hel,ss;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d%d",&h1,&m1,&h2,&m2);
printf("------+---------\n");
printf(" time | elapsed\n");
printf("------+---------\n");
printf("%2d:XX | XX",h1);
if(m1)printf(" - %d\n",m1);
else printf("\n");
hel=h2*60+m2;
ss=-m1;
for(i=h1+1;;i++)
{
if(ss+60 > hel)break;
if(i >12)i-=12;
ss+=60;
printf("%2d:XX | XX",i);
printf(" + %d\n",ss);
}
}
return 0;
}