如何修改代码以找到最小的数字,却变成长尾词?

2026-04-01 23:001阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计271个文字,预计阅读时间需要2分钟。

如何修改代码以找到最小的数字,却变成长尾词?

javapublic static void main(String[] args) { Scanner input=new Scanner(没有额外的错误。我只是无法打印最小的输入。);}

没有额外的错误。我只是无法打印最小的输入。publicstaticvoidmain(Stringargs[]){Scannerinput

没有额外的错误。我只是无法打印最小的输入。

public static void main(String args[]){ Scanner input=new Scanner(System.in); System.out.print("Marks of a student(-1 to terminate the inputting marks): "); int x=input.nextInt(); int total=0,large=0,y=0,small=0,z; z=x; while(x!=-1){ System.out.print("Marks of a student(-1 to terminate the inputting marks): "); x=input.nextInt(); total+=x; y++; if(x>=large){ large=x; } if(x

回答

small用 初始化0,因此任何大于该值的输入都将被忽略。

一种方法是用 初始化它Integer.MAX_VALUE,因此任何输入的数字都会小于或等于它。同样,large可以用 初始化Integer.MIN_VALUE。


    如何修改代码以找到最小的数字,却变成长尾词?
    标签:数字

    本文共计271个文字,预计阅读时间需要2分钟。

    如何修改代码以找到最小的数字,却变成长尾词?

    javapublic static void main(String[] args) { Scanner input=new Scanner(没有额外的错误。我只是无法打印最小的输入。);}

    没有额外的错误。我只是无法打印最小的输入。publicstaticvoidmain(Stringargs[]){Scannerinput

    没有额外的错误。我只是无法打印最小的输入。

    public static void main(String args[]){ Scanner input=new Scanner(System.in); System.out.print("Marks of a student(-1 to terminate the inputting marks): "); int x=input.nextInt(); int total=0,large=0,y=0,small=0,z; z=x; while(x!=-1){ System.out.print("Marks of a student(-1 to terminate the inputting marks): "); x=input.nextInt(); total+=x; y++; if(x>=large){ large=x; } if(x

    回答

    small用 初始化0,因此任何大于该值的输入都将被忽略。

    一种方法是用 初始化它Integer.MAX_VALUE,因此任何输入的数字都会小于或等于它。同样,large可以用 初始化Integer.MIN_VALUE。


      如何修改代码以找到最小的数字,却变成长尾词?
      标签:数字