最近在玩judge:题目入下,要求用java哦~
Find the maximum element in a set of integers. List of integers ends with EOF. Intergers are separated by whitespace characters (SPACE, TAB, NEWLINE). There are at most 10000 integers in the list, their modulii being less than 2 to 30 power (2 30).我的代码(没通过judge,问题是解决了,就是要在输入数字时以一个非int型字符来结束输入)
import java.util.Scanner;
public class Main{
public static void main(String[] args){
int bigest=0;
Scanner in=new Scanner(System.in);
while(in.hasNextInt()&&(in.)){
int temp=in.nextInt();
if(temp>bigest){
bigest=temp;
}
}
System.out.println("the bigest is:"+bigest);
}}
Find the maximum element in a set of integers. List of integers ends with EOF. Intergers are separated by whitespace characters (SPACE, TAB, NEWLINE). There are at most 10000 integers in the list, their modulii being less than 2 to 30 power (2 30).我的代码(没通过judge,问题是解决了,就是要在输入数字时以一个非int型字符来结束输入)
import java.util.Scanner;
public class Main{
public static void main(String[] args){
int bigest=0;
Scanner in=new Scanner(System.in);
while(in.hasNextInt()&&(in.)){
int temp=in.nextInt();
if(temp>bigest){
bigest=temp;
}
}
System.out.println("the bigest is:"+bigest);
}}
sheep219(sheep219)
如何具体判断
冒泡,我是读取一个,比较一个了,难道还有更简单的?
public class test {
public static void main(String[] args) {
Arrays.sort(args);
System.out.println("the bigest is:"+args[args.length-1]);
}
}
at test.main(test.java:5)
刨除异常了~
如果你是在dos提示符向运行的话:
java test 3 8 1 9 4 2 7 5
所以想问说如何解决“以回车来结束这组数字的输入”
那么in.hasNextInt()就可以结束了啊
但是我无法结束阿,你可以上机调试下看看的,输入完后还是在那里等待的