1. 程式人生 > >值按照指定順序輸出來

值按照指定順序輸出來

package 第三章;

import java.util.Scanner;

/*
File name:homework1.cpp
Author:楊柳
Date:2017/9/20
IDE:eclipse
*/
public class homework1 {

	private static final int n = 0;
	public static void main(String[] args) {
		//System.out.println("輸入一個大於零的整數:");
		// sc=new Scanner(System.in);
	   // int n=sc.nextInt();
		solve1(1376);
		}

	public static void solve1(int x) {
		System.out.println(x);
		if (x < 5000){
		     solve1(2 * x);
		}
		else{
			solve2(x/2);
		}
	}
	public static void solve2(int x) {
		System.out.println(x);
         if (x > 1376) {
			x=x/2;
			solve2(x);
		}

	}

}