JAVA,输入5个数,输出最大值,用for语句怎么做
2个回答
展开全部
int i =0;
System.out.print("Input 5 num :");
Scanner sc = new Scanner(System.in);
int temp,max;
temp = sc.nextInt();
max = temp;
for(;i<4;i++)
{
temp = sc.nextInt();
if(temp > max)
max = temp;
}
System.out.print("Max :"+ max);
System.out.print("Input 5 num :");
Scanner sc = new Scanner(System.in);
int temp,max;
temp = sc.nextInt();
max = temp;
for(;i<4;i++)
{
temp = sc.nextInt();
if(temp > max)
max = temp;
}
System.out.print("Max :"+ max);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询