/*实验2-12 计算火车运行时间*/
#include<stdio.h>
int main()
{
int m,n,a,b,c,d,x,y;
scanf("%d%d",&m,&n);
a=m/100;
b=m%100;
c=n/100;
d=n%100;
if(b<=d)
{x=c-a;
y=d-b;
}
else
{x=c-a-1;
y=60+d-b;
}
printf("traval time is %d hour(s) %d minute(s)\n",x,y);
return 0;
}
/实验2-13 计算天数/
/*实验2-13 计算天数*/
#include<stdio.h>
int main()
{
int y,m,d,leap;
scanf("%d%d%d",&y,&m,&d);
if((y%4==0&&y%100!=0)||(y%400==0))
leap=1;
else
leap=0;
switch(m)
{
case 12:d+=30;
case 11:d+=31;
case 10:d+=30;
case 9:d+=31;
case 8:d+=31;
case 7:d+=30;
case 6:d+=31;
case 5:d+=30;
case 4:d+=31;
case 3:d+=28+leap;
case 2:d+=31;
printf("this is the %dth of %d\n",d,y);
}
return 0;
}