问答题
下面的程序的功能是将数组array下标为奇数的元素相乘(数组的位置是从0开始的),并将乘积存放到变量total中。请在程序的每条横线处填入适当的语句,使程序的功能完整。
注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。
public class JiShuJi
{
public static void main(String args[ ])
{
int array[ ]={1,2,3,5,7,9};
long total= ________________________;
for(int i=1;i<=__________________ i++)
{
____________________
i++;
}
System.out.println(total);
}
}
【参考答案】
1 array.length-1; total*=array[i];[解析] 本题主要考查for循环语句和数组的知识。解......
(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)