解题思路:
注意事项:
时h:分m:秒s的转换:
h=s/3600
m=s%3600/60
s=s%60
参考代码:
import java.util.*;
public class Main {
public static void main(String[]args){
Scanner scan=new Scanner(System.in);
int s=scan.nextInt();
Time time=new Time();
time.Set(s);
time.Display();
}
}
// Time里面有h、m、s三个私有成员
class Time{
private int h,s,m;
public void Set(int s){
this.m=s%3600/60;
this.s=s%60;
this.h=s/3600;
}
public void Display(){
System.out.print(this.h+":"+this.m+":"+this.s);
}
}
0.0分
1 人评分
C二级辅导-计负均正 (C语言代码)浏览:588 |
点我有惊喜!你懂得!浏览:1435 |
C语言训练-列出最简真分数序列* (C语言代码)浏览:503 |
C语言训练-角谷猜想 (C语言代码)浏览:1705 |
【明明的随机数】 (C++代码)浏览:779 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:377 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:262 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:561 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:557 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:570 |