} System.out.println("Max is :"+a[0]); } }这个比较好用!!
import java.io.*;public class SelectMax{ public static void main( String [] args ){
int max = 0 ; while( true ){ System.out.print( "Please input a number , zero for exit : " ); int temp = Read.readInt( ); if( temp == 0 ) { break ; } if ( temp == -1 ){ System.out.println( "bad number , try agin " ); continue ; } if( temp > max ){ max = temp ; } } if( max == 0 ){ System.out.println( "You didn't input any nuber" ); }else { System.out.println( "The Max number you had input is " + max ); } } }/* * Read 类用于读入数据。 * */class Read{
private static BufferedReader br = null ;
/* * 静态代码块初始化 br . */ static{ try{ br = new BufferedReader( new InputStreamReader( System.in ) ); }catch( Exception e ){ } }
/* * 读入一个整数, */ public static int readInt( ){ try{ String str = br.readLine( ); return Integer.parseInt( str.trim() ); }catch( Exception e ){ return -1 ; } }}
import java.io.IOException;
import java.io.InputStreamReader;public class Getmax { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int max = 0;
while(true){
System.out.println("请输入数字,-1结束");
String num="";
try {
num = br.readLine();
if(max<Integer.parseInt(num)){
max = Integer.parseInt(num);
}
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
if(num.equalsIgnoreCase("quit"))
break;
}
System.out.println("Max is :"+max);
} }
import java.io.IOException;
import java.io.InputStreamReader;public class Getmax { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int max = 0;
while(true){
System.out.println("请输入数字,-1结束");
String num="";
try {
num = br.readLine();
if(max<Integer.parseInt(num)){
max = Integer.parseInt(num);
}
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
if(num.equalsIgnoreCase("-1"))
break;
}
System.out.println("Max is :"+max);
} }
//import java.io.IOException;
//import java.io.InputStreamReader;public class Getmax
{ /**
* @param args
*/
public static void main(String[] args)
{
int i,n=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入比较数字的个数:");
try
{
n = Integer.parseInt(br.readLine());
}
catch (IOException e) {}
int[] a;
a = new int[n];
//int max=0;
for(i=0;i<a.length;i++)
{
System.out.println("请输入第"+(i+1)+"个数字:");
//String num="";
BufferedReader br1=new BufferedReader(new InputStreamReader(System.in));
try
{
a[i] = Integer.parseInt(br1.readLine());
if(a[0]<a[i])
{
a[0] = a[i];
}
}
catch (IOException e) {}
}
System.out.println("Max is :"+a[0]);
} }这个比较好用!!
import java.io.*;public class SelectMax{ public static void main( String [] args ){
int max = 0 ; while( true ){
System.out.print( "Please input a number , zero for exit : " );
int temp = Read.readInt( );
if( temp == 0 ) {
break ;
}
if ( temp == -1 ){
System.out.println( "bad number , try agin " );
continue ;
} if( temp > max ){
max = temp ;
}
} if( max == 0 ){
System.out.println( "You didn't input any nuber" );
}else {
System.out.println( "The Max number you had input is " + max );
} }
}/*
* Read 类用于读入数据。
*
*/class Read{
private static BufferedReader br = null ;
/*
* 静态代码块初始化 br .
*/
static{
try{
br = new BufferedReader(
new InputStreamReader(
System.in ) );
}catch( Exception e ){
}
}
/*
* 读入一个整数,
*/
public static int readInt( ){
try{
String str = br.readLine( );
return Integer.parseInt( str.trim() );
}catch( Exception e ){
return -1 ;
}
}}