课堂作业
源代码 :
import java.util.Scanner;
public class Hee
{
int Largest(int list[],int length)
{
if (list == null || length == 0)
{return 0;}
else
{
int i;
int max=list[0];
for( i=0;i<length;i++)
{
if(list[i]>max)
{
max=list[i];
}
}
return max;
}
}
public static void main(String args[])
{
Scanner scanner=new Scanner(System.in);
System.out.println("请输入打印的次数");
int a =scanner.nextInt();
for(int i=0;i<a;i++)
{
System.out.println("请输入数组的长度");
int t=scanner.nextInt();
int[] b=new int[t];
for(int c=0;c<t;c++)
{
System.out.println("请输入第"+(c+1)+"整数");
b[c]=scanner.nextInt();
}
Hee s=new Hee();
System.out.println(s.Largest(b,b.length));
}
}
}