我叫王超然,是一名电脑爱好者,现在在新加坡留学上高一.我立志成为一名电脑人才,愿意在这里与大家一同分享我玩转电脑的心得.O-level华文考了A-One哈哈!
天气: 晴朗
心情: 高兴
/*filename:P6Q09
* Name:Wang Chaoran
* Description:
(Finding the smallest element) Write a method that finds the smallest element in an array of integers. Use {1, 2, 4, 5, 10, 100, 2, –22} to test the method.
*/
class P6Q09{
public static void main(String[] args){
int[] test = {1, 2, 4, 5, 10, 100, 2,-22};
System.out.println("The min of {1, 2, 4, 5, 10, 100, 2,-22} is: "+min(test));
}
static int min(int[] array){
int min =array[0];
for(int i=1;i<array.length;i++)
if(min>array[i])
min=array[i];
return min;
}
}
导入论坛查看(60)回复(0)引用(0)好评(0) 差评(0)
加入收藏
编辑
审核
TAG:
computing