Time类定义

    import java.util.*;
class Time{
	int h;
	int m;
	int s;
	public Time(int h,int m,int s) {
		if(h<=0||h>12)
			h=12;
		this.h=h;
		if(m<0||m>59)
			m=0;
		this.m=m;
		if(s<0||s>59)
			s=0;
		this.s=s;
	}
}
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt();
		int M=sc.nextInt();
		int S=sc.nextInt();
		Time time=new Time(H,M,S);
		System.out.printf("%02d:%02d:%02d\n",time.h,time.m,time.s);
		sc.close();
	}
}

相关文章:

  • 2021-07-13
  • 2021-12-05
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-15
  • 2021-07-09
  • 2021-05-19
  • 2022-12-23
相关资源
相似解决方案