package java1;
//导包
import java.util.*;
class mygame
{
public static void main(String[] args)
{
// 导用方法
shop();
}
public static void shop()
{
String[] shopNames = new String[100];// 创建安置商品的数组
int[] shopNums = new int[100];// 创建商品的编号
// 给对应商品进行编号
shopNames[0] = "苹果";
shopNames[1] = "梨";
shopNames[2] = "草莓";
shopNames[3] = "饼干";
shopNames[4] = "可乐";
shopNames[5] = "酒";
while (true)
{
// 键盘输入数字
Scanner ac = new Scanner(System.in);
int sc = ac.nextInt();
// 利用for循环查找数字对应的商品
for (int i = 0; i < shopNames.length; i++)
{
int shopNum = shopNums[i];
}
// 打印输出
System.out.println(shopNames[sc]);
}
}
}
java中的二维数组
最新推荐文章于 2022-01-17 17:55:07 发布