问题描述
解决方案
Scanner sc = new Scanner(System.in);
String[] input = new String[26];
int i = 0;
do {
input[i] = sc.next();
i++;
} while (!input[i - 1] .equals("-1") );
in.close();
解决方案二:
while(i!=-1){
.........
}
解决方案三:
system.out.print(“ ”),是输出“”内的字符串
解决方案四:
while(i!=-1){
.........
}
解决方案五:
参考
public static void main(String[] args) {
// TODO Auto-generated method stub
TreeSet treeSet = new TreeSet();
Scanner scanner = new Scanner(System.in);
// scanner.useDelimiter("n");
while (scanner.hasNextInt()) {
int i = scanner.nextInt();
if (i == -1) {
scanner.close();
break;
} else {
treeSet.add(i);
}
}
Iterator iterator = treeSet.iterator();
System.out.println(treeSet);
while (iterator.hasNext()) {
Integer a = iterator.next();
if ((Math.sqrt(a) % 1) == 0) {
System.out.println(a + "是平方数");
}
}
}