学习笔记-pass迭代

来源:互联网 发布:linux局域网共享文件 编辑:程序博客网 时间:2024/05/16 16:07
public class Pass {
 public static void main(String[] args){
  int temp;
  int i = 0;
  int j;
  String str = null;
  BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
  try {
   str = input.readLine();
  } catch (IOException e) {

   e.printStackTrace();
  }
  StringTokenizer st = new StringTokenizer(str);
  int [] a = new int[st.countTokens()];
  while(st.hasMoreTokens()){
   a[i] = Integer.parseInt(st.nextToken());
   i++;
  }
  
  for(i = 0 ;i <a.length-1;i++)
   for(j = i+1; j<a.length;j++)
    
    if(a[i]>a[j]){
     temp = a[i];
     a[i] = a[j];
     a[j] = temp;
    }
  for(i=0 ; i<a.length;i++)
   System.out.print(a[i]+"/t");
 }