用java语言写

http://img.mukewang.com/5721c0250001e30d03710547.jpg

慕移动0678692
浏览 1372回答 3
3回答

Caballarii

    static int argument;     static int count=0;          public static void main(String[] args){                 argument=5;         printResult("",argument);         System.out.println("总共"+count+"种");     }     public static void printResult(String result,int left){         if(left==1){             System.out.print(argument+"=");             for(int i=0;i<result.length();i++){                 System.out.print(result.charAt(i)+"+");             }             System.out.print(1);             System.out.println();             count++;         }         else if(left==2){             System.out.print(argument+"=");             for(int i=0;i<result.length();i++){                 System.out.print(result.charAt(i)+"+");             }             System.out.print(2);             System.out.println();             count++;             printResult(result+"1",left-1);         }         else{             printResult(result+"1",left-1);             printResult(result+"2",left-2);         }     }不光把铺法数量输出了,还把具体的铺法输出了
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java