星期一, 10月 24, 2005

max_min

import java.io.*;
import java.io.IOException;
public class testmin
{
public static void main(String[] args) throws IOException
{
BufferedReader keybord = new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Please enter some numbers");
String inputString1 =keyboard.readLine();
int next1 = Integer.parseInt(inputString1);
int theNumber=next1;
int a[]={theNumber};
int i,j;
for (i = 0; ; i++);
System.out.println(a[i]);
for (i = 0; ; i++);
int k,temp,s;
for (i = 0; ; i++){
s=0;
for (j = 0; ; i++)
{
if(a[j]>a[j=+1]){
s=1;
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
if(s !=1)
break;
}
System.out.println("the min is"+a[0]);
System.out.println("the max is"+a[j+1]);

}
}

試了好久~~好像還是不太行

0 Comments:

張貼留言

<< Home