为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

求一组数中的最大值和最小值

2017-12-02 3页 doc 13KB 57阅读

用户头像

is_079973

暂无简介

举报
求一组数中的最大值和最小值求一组数中的最大值和最小值 求一组数中的最大值和最小值。 例如,程序运行输出格式如下: table: 84 40 16 3 10 49 28 76 94 70 Max=94 Min=3 import java.util.Scanner; public class Table { public static int[] random(int n) //产生数组 { int table[] = new int[n]; for(int i = 0; i table[i]) { temp = table[i...
求一组数中的最大值和最小值
求一组数中的最大值和最小值 求一组数中的最大值和最小值。 例如,程序运行输出格式如下: table: 84 40 16 3 10 49 28 76 94 70 Max=94 Min=3 import java.util.Scanner; public class Table { public static int[] random(int n) //产生数组 { int table[] = new int[n]; for(int i = 0; i < table.length ; i++) { table[i] = (int)(Math.random()*100); } return table; } public static void print(int table[]) //输出数组 { for(int i = 0;i < table.length ; i++) { System.out.print(" "+table[i]); } System.out.println(); } public static int max(int table[]) // 求最大值 { int temp = table[0]; for(int i = 0; i < table.length; i++) { if(temp < table[i]) { temp = table[i]; } } return temp; } public static int min(int table[]) //求最小值 { int temp = table[0]; for(int i = 0; i < table.length; i++) { if(temp > table[i]) { temp = table[i]; } } return temp; } public static void main(String args[]) { Scanner sc = new Scanner(System.in); int i = sc.nextInt(); int b[] = random(i); System.out.print("table="); print(b); System.out.println("max = "+max(b)); System.out.println("min = "+min(b)); } }
/
本文档为【求一组数中的最大值和最小值】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索