简单的拆分字符串和冒泡排序的算法

package test;
 
 import java.io.IOException;
 import java.io.StringReader;
 
 public class TestIO {
 	public static void main(String[] args) throws IOException {
 		/**
 		 * 最简单的拆分字符串的方法
 		 */
 		StringReader sr = new StringReader("aaa我爱北京天安门,Ya");
 		int c;
 		while ((c = sr.read()) != -1) {
 			System.out.print((char) c);
 		}
 		System.out.println();
 
 		/**
 		 * 最简单的冒泡排序算法
 		 */
 		int[] a = { 1, 3, 2, 5, 4, 7, 6, 9, 8, 10 };
 		for (int i = 0; i < a.length; i++) {
 			for (int j = 0, temp = 0; j < a.length - i - 1; j++) {
 				if (a[j] < a[j + 1]) {
 					temp = a[j];
 					a[j] = a[j + 1];
 					a[j + 1] = temp;
 				}
 			}
 		}
 		for (int n : a)
 			System.out.print(n + ",");
 	}
 }
 

点赞