java请具体讲一下每行的含义
importjava.util.Scanner;publicclassc1{publicstaticvoidmain(String[]args){intmax,min,x...
import java.util.Scanner;
public class c1{
public static void main(String[] args) {
int max,min,x,k;
float sum,ave;
Scanner sc = new Scanner(System.in);
System.out.println("please enter score of student:");
x=sc.nextInt();
max=0;
min=0;
sum=0;
k=1;
while(k<=5)
{ x=sc.nextInt();
sum+=x;
if(x<max) max=x;
else if(x>min) min=x;
k++;}
ave=sum/5;
System.out.println("average="+ave+";max="+max+";min="+min);
}
}
这是老师出的题目,结果他说很简单,就没有讲了,反正我是不懂,书上也没有,所以问大佬,请尽可能的详细解释! 展开
public class c1{
public static void main(String[] args) {
int max,min,x,k;
float sum,ave;
Scanner sc = new Scanner(System.in);
System.out.println("please enter score of student:");
x=sc.nextInt();
max=0;
min=0;
sum=0;
k=1;
while(k<=5)
{ x=sc.nextInt();
sum+=x;
if(x<max) max=x;
else if(x>min) min=x;
k++;}
ave=sum/5;
System.out.println("average="+ave+";max="+max+";min="+min);
}
}
这是老师出的题目,结果他说很简单,就没有讲了,反正我是不懂,书上也没有,所以问大佬,请尽可能的详细解释! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询