输出1,2,2,3,4,5的所有排列组合,4不能在第三位,3和5不能相邻
来源:互联网 发布:mac比较好的杀毒软件 编辑:程序博客网 时间:2024/04/29 20:26
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ public class MySort { private List<string> s0 = new List<string>(); private List<string> r0 = new List<string>(); public MySort() { s0.Add("1"); s0.Add("2"); s0.Add("2"); s0.Add("3"); s0.Add("4"); s0.Add("5"); } private void Sort() { string str=""; for(int i0=0;i0<s0.Count;i0++){ List<string> s1=getNextList(s0,i0); for(int i1=0;i1<s1.Count;i1++){ List<string> s2=getNextList(s1,i1); for(int i2=0;i2<s2.Count;i2++){ List<string> s3=getNextList(s2,i2); for(int i3=0;i3<s3.Count;i3++){ List<string> s4=getNextList(s3,i3); for(int i4=0;i4<s4.Count;i4++){ List<string> s5=getNextList(s4,i4); for(int i5=0;i5<s5.Count;i5++){ str=s0[i0]+s1[i1]+s2[i2]+s3[i3]+s4[i4]+s5[i5]; if (check(str)&&!r0.Contains(str)) { r0.Add(str); } } } } } } } } private List<String> getNextList(List<String> inList, int i) { List<String> rs = new List<String>(); rs.AddRange(inList); rs.Remove(rs[i]); return rs; } private bool check(String s) { if (s[2] == '4' || s.Contains("35") || s.Contains("53")) { return false; } return true; } private void printStr() { int lineN = 10; foreach(var s in r0) { Console.Write(s + " "); if (lineN-- == 1) { Console.WriteLine(); lineN = 10; } } Console.WriteLine(r0.Count); } static void Main(string[] args) { MySort mySort = new MySort(); mySort.Sort(); mySort.printStr(); Console.Read(); } } }
- 输出1,2,2,3,4,5的所有排列组合,4不能在第三位,3和5不能相邻
- 输出1,2,2,3,4,5的所有排列组合,4不能在第三位,3和5不能相邻
- 输出1,2,2,3,4,5的所有排列组合,4不能在第三位,3和5不能相邻
- 输出1,2,2,3,4,5的所有排列组合,4不能在第三位,3和5不能相邻
- 输出1,2,2,3,4,5的所有排列组合,4不能在第三位,3和5不能相邻
- 面试题:输出1,2,2,3,4,5的所有排列组合,4不能在第三位,3和5不能相邻
- 输出{1,2,2,3,4,5}排列组合,4不能在第三位,3和5不能相邻
- 输出1,2,2,3,4,5的所有排列组合,4不能在第3位,3和5不能相邻
- 有1,2,2,3,4,5六个数,要求输出他们组合的全排列,4不能在第三位,5和3不能相邻
- 【2015/10/13】打印1,2,2,3,4,5六个数的组合,4不在第三位,3和5不能相邻
- 用 1,2,2,3,4,5 六个数字,打印出所有不同的排列,要求:"4"不能在第三位,"3"与"5"不能相连
- 140 打印出所有不同的排列 4不能在第三位,3与5不能相连
- "4"不能在第三位,"3"与"5"不能相连。
- 122345这6个数字,输出它所有可能的组合;要求4不能在第3位,3和5不能相连。
- java面试题 用1,2,2,3,4,5六个数字,组成一个6位数。 第三位数不能是2;3和5不能相邻。
- 用1、2、2、3、4、5这六个数字,用java写一个main函数,打印出所有不同的排列, 如:512234、412345等,要求:"4"不能在第三位,"3"与"5"不能相连.
- 用1、2、2、3、4、5这六个数字,写一个main函数,打印出所有不同的排列, 如:512234、412345等,要求:"4"不能在第三位,"3"与"5"不能相连.
- 1、2、2、3、4、5这六个数字,用java写一个main函数,打印出所有不同的排列, 如:512234、412345等.要求:"4"不能在第三位,"3"与"5"不能相连.
- google Snappy
- 验证码相关资料
- curl应用总结(一)
- 暗恋,一种美丽的痛
- 使用 Spring 2.5 基于注解驱动的 Spring MVC
- 输出1,2,2,3,4,5的所有排列组合,4不能在第三位,3和5不能相邻
- curl应用总结(二)
- win7旗舰版上装VS2010错误(提示:miicrosoft 应用程序报告[安装失败])
- Linux 的系统服务及其配置
- curl应用总结(三)
- POJ 2085 treap O(nlogn) 与 贪心 O(n)算法
- vim NerdTree 常用命令
- 定位程序Crash常用工具和方法
- android Theme使用总结