微软100题-天天做-第21题
来源:互联网 发布:2017淘宝冷门暴利产品 编辑:程序博客网 时间:2024/05/30 04:41
第21题(数组)
2010年中兴面试题
编程求解:
输入两个整数 n 和 m,从数列1,2,3.......n 中 随意取几个数,
2010年中兴面试题
编程求解:
输入两个整数 n 和 m,从数列1,2,3.......n 中 随意取几个数,
使其和等于 m ,要求将其中所有的可能组合列出来.
package com.microsoft;import java.util.ArrayList;import java.util.List;public class MSumOfN {private static List<Integer> result=new ArrayList<Integer>();public static void fenjie(int m,int n){if(m<0){return;}if(n<=0){return;}if(m==0){for(int i=0;i<result.size();i++){System.out.print(result.get(i)+"+");}System.out.println();}if(n>m){n=m;}result.add(n);fenjie(m-n,n-1);if(result.size()>0){result.remove(result.size()-1);fenjie(m,n-1);}}public static void main(String[] args) {fenjie(20,10);}}
0 0
- 微软100题-天天做-第21题
- 微软面试100题-天天做-第5题
- 微软面试100题-天天做-第6题
- 微软100题-天天做-第7题
- 微软100题-天天做-第8题
- 微软100题-天天做-第9题
- 微软100题-天天做-第10题
- 微软100题-天天做-第11题
- 微软100题-天天做-第12题
- 微软100题-天天做-第13题
- 微软100题-天天做-第14题
- 微软100题-天天做-第15题
- 微软100题-天天做-第16题
- 微软100题-天天做-第17题
- 微软100题-天天做-第18题
- 微软100题-天天做-第19题
- 微软100题-天天做-第20题
- 微软100题-天天做-第22题
- cantor表
- NYOJ--相同的和
- 就客户和客户好好的话空间的
- Div 的使用
- 在主线程中慎用WaitForSingleObject (WaitForMultipleObjects)
- 微软100题-天天做-第21题
- 查看 Apache并发请求数及其TCP连接状态
- 使用C#开发身份证号生成器
- Android 文件上传至服务器
- FOJ2014年3月赛部分题解. FZOJ 2152 2154 2155 2156 2159
- About Lightmap Baking
- Apache 配置文件详解
- mysqlbinlog 查看mysql bin 日志
- 光照贴图深入学习 Lightmapping In-Depth