日期:2014-05-20 浏览次数:21061 次
大概想到一种方法,感觉好怪。。。	public static void main(String[] args) throws Exception {
		fun(2);
		fun(3);
		fun(4);
	}
	public static void fun(int n) {
		StringBuilder builder = new StringBuilder();
		for (int i = 1, step = 1; i <= n; i += step) {
			builder.append(i);
			if (i == 1) {
				step = 1;
			}
			if (i == n) {
				step = -1;
			}
			if (builder.length() == 20) {
				break;// 不能一直循环
			}
		}
		System.out.println(builder);
	}