[size=medium]输入四3个数字,输出最大值
package com.lovo;
/**
* 输入四3个数字,输出最大值
*/
import java.util.Scanner;
public class Test7 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in );
System.out.println("请输入:");
int x = sc.nextInt();
int max =x;
for (int i=1;i<=3;i++){
x = sc.nextInt();
if(x>max){
max=x;
}
i = i+1;
}
System.out.println(max);
}
}
[color=red]输入秒,输出时,分,秒[/color]
package com.lovo;
import java.util.Scanner;
/**
*
* @author WenChuan
* 输入秒,输出时,分,秒
*
*/
public class Time {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入秒:");
int m = sc.nextInt();
int hour =m/3600;
int minutes = m%3600/60;
int seconds = m%60;
if(hour<10){
System.out.print("0"+hour+":");
}else{
System.out.print(hour+":");
}
if(minutes<10){
System.out.print("0"+minutes+":");
}else{
System.out.print(minutes+":");
}
if(seconds<10){
System.out.print("0"+seconds);
}else{
System.out.print(seconds);
}
}
}[/size]
package com.lovo;
/**
* 输入四3个数字,输出最大值
*/
import java.util.Scanner;
public class Test7 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in );
System.out.println("请输入:");
int x = sc.nextInt();
int max =x;
for (int i=1;i<=3;i++){
x = sc.nextInt();
if(x>max){
max=x;
}
i = i+1;
}
System.out.println(max);
}
}
[color=red]输入秒,输出时,分,秒[/color]
package com.lovo;
import java.util.Scanner;
/**
*
* @author WenChuan
* 输入秒,输出时,分,秒
*
*/
public class Time {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入秒:");
int m = sc.nextInt();
int hour =m/3600;
int minutes = m%3600/60;
int seconds = m%60;
if(hour<10){
System.out.print("0"+hour+":");
}else{
System.out.print(hour+":");
}
if(minutes<10){
System.out.print("0"+minutes+":");
}else{
System.out.print(minutes+":");
}
if(seconds<10){
System.out.print("0"+seconds);
}else{
System.out.print(seconds);
}
}
}[/size]