for(int i=1;i<=num;i++){
System.out.println("请输入您要租的第"+i+"种车的序号:");
cars[i-1][i-1]=input.nextInt();
System.out.println("请输入您要租的第"+i+"种车的数量:");
cars[i-1][i]=input.nextInt();
System.out.println("请输入您要租的第"+i+"种车的天数:");
cars[i-1][i+1]=input.nextInt();
int money=RentCar[cars[i-1][i-1]-1].price*cars[i-1][i+1]*cars[i-1][i];
cars[i-1][i+2]=money;
money=0;
sum += cars[i-1][i];
if(sum==num)
break;
}/*运行时会出现Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4 at dada.TestData.show(TestData.java:59) at dada.TestData.dada(TestData.java:19) at dada.Test.main(Test.java:7)*/显示是cars[i-1][i+2]=money;的问题
添加回答
举报
0/150
提交
取消