2个回答
展开全部
import java.util.Scanner;
public class Foo {
public static void main(String[] args) {
System.out.println("请输入秒数");
Scanner sc = new Scanner(System.in);
int seconds = sc.nextInt();
int day=0,hours=0,minutes=0;
day = seconds/(60*60*24);
seconds -= day*60*60*24;
hours = seconds/(60*60);
seconds -= hours*60*60;
minutes= seconds/60;
seconds -= minutes*60;
System.out.println("总共"+day+"天"+hours+"小时"+minutes+"分"+seconds+"秒");
}
}
引用dark19861201的回答:
import java.util.Scanner;public class Foo { public static void main(String[] args) { System.out.println("请输入秒数"); Scanner sc = new Scanner(System.in); int seconds = sc.nextInt(); int day=0,hours=0,minutes=0; day = seconds/(60*60*24); seconds -= day*60*60*24; hours = seconds/(60*60); seconds -= hours*60*60; minutes= seconds/60; seconds -= minutes*60; System.out.println("总共"+day+"天"+hours+"小时"+minutes+"分"+seconds+"秒"); }}
import java.util.Scanner;public class Foo { public static void main(String[] args) { System.out.println("请输入秒数"); Scanner sc = new Scanner(System.in); int seconds = sc.nextInt(); int day=0,hours=0,minutes=0; day = seconds/(60*60*24); seconds -= day*60*60*24; hours = seconds/(60*60); seconds -= hours*60*60; minutes= seconds/60; seconds -= minutes*60; System.out.println("总共"+day+"天"+hours+"小时"+minutes+"分"+seconds+"秒"); }}
展开全部
计算时分秒时要进行取余之后再计算
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询