java 数组拼成一个整数_java实现游戏:有一个整数数组

展开全部

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] + " ");

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值