public static void printTime(int time)
{
if(time<60)//小于60时 直接打印秒
{
System.out.println(time+"秒");
}
if(time<3600&time%60==0)//所以要分开讨论
{
int m=time/60;
System.out.println(m+"分");
}
if(time>60&time<3600&time%60!=0)//两边都需要判断 所以用&
{
int m=time/60;
int s=time%60;
System.out.println(m+"分"+s+"秒");
}
if(time%3600==0&time<(3600*24))
{
int h=time/3600;
System.out.println(h+"小时");
}
if(time>3600&time<(3600*24)&time%3600!=0)
{
int h=time/3600;
int m=(time%3600)/60;
int s=time%60;
System.out.println(h+"小时"+m+"分"+s+"秒");
}
if(time%3600*24==0&time>3600*24)
{
int d=time/3600*24;
System.out.println(d+"天");
}
if(time>3600*24)
{
int d=time/(3600*24);
int h=time%(3600*24)/(3600);
int m=time%(3600*24)%3600/60;
int s=time%60;
System.out.println(d+"天"+h+"小时"+m+"分"+s+"秒");
}
}
}