展开全部
x给你稍稍的改动了一下,运行正常。e68a84e8a2ad3231313335323631343130323136353331333332613738你看一下吧。import java.util.Scanner;
public class Game {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int index = 0;
int[] sum = new int[] { 1, 4, 6, 9, 13, 16, 19, 28, 40, 100 };
int[] look = new int[sum.length - 1];
System.out.println("数组中的数字有:");
for (int i = 0; i < sum.length; i++) {
System.out.print(sum[i] + " ");
}
System.out.print("\n请输入需要删除的数字:");
int cancel = input.nextInt();
boolean exists = false;
for (int i = 0; i < sum.length; i++) {
if (sum[i] == cancel) {
exists = true;
}
}
if (!exists) {
System.out.println("你要删除的数字不存在。");
return;
}
for (int i = 0; i < sum.length; i++) {
if (sum[i] == cancel) {
continue;
}
look[index++] = sum[i];
}
System.out.println("删除后为:");
for (int i = 0; i < look.length; i++) {
System.out.print(look[i] + " ");
}
}
}