public class Example2_4
{
public static void main(String [] aa)
{
byte score[] = {1,2,3,4,5,6,7,8,9,10
};
System.out.println("数组元素之和 ="+score[0]+score[1]+score[2]+score[3]+score[4]+score[5]+score[6]+score[7]+score[8]+score[9]);
}
}
这个程序要怎么用for、while和do{}while改写,我自己就这样写,可就是行不通,我想了很久也没想出来,请大家帮个忙!
我改写的:
public class Example2_4_1
{
public static void main(String args[])
{
int i=0;++i;
byte score[] = new byte[i];
score[i] = ++i;
do
{
System.out.println(score[i]);
}while(i<=10);
}
}
[求助]我想了很久的问题!