package nan;
import java.util.Random;
public class Nan {
public static void main(String[]args)
{
Random random=new Random();
float f1=random.nextFloat();
int a=Math.round(100*f1);
float f2=random.nextFloat();
int b=Math.round(100*f2);
System.out.println("max("+a+","+b+")="+max(a,b));
System.out.println("max("+f1+","+f2+")="+max(f1,f2));
float f3=random.nextFloat();
int c=Math.round(100*f3);
System.out.println("max("+a+","+b+","+c+")="+max(a,b,c));
}
static float max(float f1,float f2)
{
if(f1>f2)
{
return f1;
}
else
{
return f2;
}
}
static int max(int m,int n)
{
if(m>n)
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载