public class HelloWorld {
public static void main(String[] args){
int num[]=new int[]{61,23,4,74,13,148,20};
int B=num[0];
int S=num[0];
int sum=0;
double avg=0;
int i;
for(i=0;i<num.length;i++);{
sum=sum+num[i];
if(B<=num[i]){
B=num[i];
}else if(S>=num[i]){
S=num[i];
}
}
avg=sum/7;
System.out.println(B+S+sum+avg);
}
}哪里出问题了??
public class Shuzu { public static void main(String[] args){ int num[]=new int[]{61,23,4,74,13,148,20}; int B=num[0]; int S=num[0]; int sum=0; double avg=0; int i; for(i=0;i<num.length;i++){ sum=sum+num[i]; if(B<=num[i]){ B=num[i]; }else if(S>=num[i]){ S=num[i]; } } avg=sum/7; System.out.println(S); System.out.println(B); System.out.println(B+S+sum+avg); } }
for循环后加了分号.....
范围没超啊。。。。