用JAVA 编写程序,从键盘读入10个整数存入数组,输出最大值,最小值及它们所在数组中的位置
import java.io.*;
import java.lang.*;
import java.util.StringTokenizer;
class array
{
public static void main(String args[])
{
StringTokenizer st=new StringTokenizer(\"10 20 30 40\");
String s=\"\";
int[] b=new int[10];
int Max=0,Min=0;
int count=0;
System.out.println(\"输入10个数字用空格隔开如:1 10 31 45 57 6 70 18 29 50\");
try
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
s=in.readLine();
st=new StringTokenizer(s);
}
catch(Exception e)
{
System.out.print(e.getMessage());
}
while(st.hasMoreTokens())
{
b[count]=Integer.parseInt(st.nextToken());
count++;
}
Min=b[0];
for(int i=0;i
if(Max{
Max=b[i];
}
else if(Min>b[i])
{
Min=b[i];
}
}
System.out.println(\"Max:\"+Max);
System.out.println(\"Min:\"+Min);
}
}