本帖最后由 郑飞 于 2014-11-2 19:39 编辑
- package com.itheima.io;
- class Test
- {
- public static void main(String[] args)
- {
- StringBuilder sb = new StringBuilder();
- test3(8,sb);
- System.out.println(sb.reverse());
-
- }
- public static void test3(int num,StringBuilder sb)
- {
- if (num>1)
- test3(num/2,sb.append(num%2));
- else
- sb.append(1);
- }
- }
复制代码
|