最近在做数据分析系统,里面涉及到组合排列的问题,查找了很多的资料,但是感觉很多资料都是比较零散的,达不到项目需求。后来经过一段的时间的探索,终于实现了组合排列的功能。下面我就来简单说说吧。 需求描述: 要实现的功能就是字符或数字的组合排列。例如 ...
最近在做数据分析系统,里面涉及到组合排列的问题,查找了很多的资料,但是感觉很多资料都是比较零散的,达不到项目需求。
后来经过一段的时间的探索,终于实现了组合排列的功能。下面我就来简单说说吧。
需求描述:
要实现的功能就是字符或数字的组合排列。例如:ab 的所有组合为:ab,ba ; ab的所有不重复排列为:ab。
其实这也是彩票中常说的直选和组选。效果图如下:
功能实现
这里就不多说了,直接贴上实现代码吧。
1.窗体界面设计
设计代码:
1 partial class FrmDemo 2 { 3 /// <summary> 4 /// 必需的设计器变量。 5 /// </summary> 6 private System.ComponentModel.IContainer components = null; 7 8 /// <summary> 9 /// 清理所有正在使用的资源。 10 /// </summary> 11 /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> 12 protected override void Dispose(bool disposing) 13 { 14 if (disposing && (components != null)) 15 { 16 components.Dispose(); 17 } 18 base.Dispose(disposing); 19 } 20 21 #region Windows 窗体设计器生成的代码 22 23 /// <summary> 24 /// 设计器支持所需的方法 - 不要 25 /// 使用代码编辑器修改此方法的内容。 26 /// </summary> 27 private void InitializeComponent() 28 { 29 this.label5 = new System.Windows.Forms.Label(); 30 this.btnAll2 = new System.Windows.Forms.Button(); 31 this.btnAll3 = new System.Windows.Forms.Button(); 32 this.groupBox3 = new System.Windows.Forms.GroupBox(); 33 this.txtAll = new System.Windows.Forms.TextBox(); 34 this.label4 = new System.Windows.Forms.Label(); 35 this.btnNot3 = new System.Windows.Forms.Button(); 36 this.btnNot2 = new System.Windows.Forms.Button(); 37 this.txtnot = new System.Windows.Forms.TextBox(); 38 this.groupBox2 = new System.Windows.Forms.GroupBox(); 39 this.groupBox1 = new System.Windows.Forms.GroupBox(); 40 this.label3 = new System.Windows.Forms.Label(); 41 this.label1 = new System.Windows.Forms.Label(); 42 this.txtShow = new System.Windows.Forms.TextBox(); 43 this.lbCount = new System.Windows.Forms.Label(); 44 this.groupBox3.SuspendLayout(); 45 this.groupBox2.SuspendLayout(); 46 this.groupBox1.SuspendLayout(); 47 this.SuspendLayout(); 48 // 49 // label5 50 // 51 this.label5.AutoSize = true; 52 this.label5.Location = new System.Drawing.Point(13, 35); 53 this.label5.Name = "label5"; 54 this.label5.Size = new System.Drawing.Size(65, 12); 55 this.label5.TabIndex = 20; 56 this.label5.Text = "输入内容:"; 57 // 58 // btnAll2 59 // 60 this.btnAll2.Location = new System.Drawing.Point(71, 76); 61 this.btnAll2.Name = "btnAll2"; 62 this.btnAll2.Size = new System.Drawing.Size(90, 35); 63 this.btnAll2.TabIndex = 15; 64 this.btnAll2.Text = "2组合"; 65 this.btnAll2.UseVisualStyleBackColor = true; 66 this.btnAll2.Click += new System.EventHandler(this.btnAll2_Click); 67 // 68 // btnAll3 69 // 70 this.btnAll3.Location = new System.Drawing.Point(165, 76); 71 this.btnAll3.Name = "btnAll3"; 72 this.btnAll3.Size = new System.Drawing.Size(90, 35); 73 this.btnAll3.TabIndex = 11; 74 this.btnAll3.Text = "3组合"; 75 this.btnAll3.UseVisualStyleBackColor = true; 76 this.btnAll3.Click += new System.EventHandler(this.btnAll3_Click); 77 // 78 // groupBox3 79 // 80 this.groupBox3.Controls.Add(this.label5); 81 this.groupBox3.Controls.Add(this.btnAll2); 82 this.groupBox3.Controls.Add(this.txtAll); 83 this.groupBox3.Controls.Add(this.btnAll3); 84 this.groupBox3.Location = new System.Drawing.Point(22, 189); 85 this.groupBox3.Name = "groupBox3"; 86 this.groupBox3.Size = new System.Drawing.Size(369, 144); 87 this.groupBox3.TabIndex = 18; 88 this.groupBox3.TabStop = false; 89 this.groupBox3.Text = "取所有组合"; 90 // 91 // txtAll 92 // 93 this.txtAll.Location = new System.Drawing.Point(85, 32); 94 this.txtAll.Name = "txtAll"; 95 this.txtAll.Size = new System.Drawing.Size(239, 21); 96 this.txtAll.TabIndex = 12; 97 this.txtAll.Text = "abc012"; 98 // 99 // label4100 // 101 this.label4.AutoSize = true;102 this.label4.Location = new System.Drawing.Point(13, 30);103 this.label4.Name = "label4";104 this.label4.Size = new System.Drawing.Size(65, 12);105 this.label4.TabIndex = 19;106 this.label4.Text = "输入内容:";107 // 108 // btnNot3109 // 110 this.btnNot3.Location = new System.Drawing.Point(167, 59);111 this.btnNot3.Name = "btnNot3";112 this.btnNot3.Size = new System.Drawing.Size(90, 35);113 this.btnNot3.TabIndex = 18;114 this.btnNot3.Text = "3组合";115 this.btnNot3.UseVisualStyleBackColor = true;116 this.btnNot3.Click += new System.EventHandler(this.btnNot3_Click);117 // 118 // btnNot2119 // 120 this.btnNot2.Location = new System.Drawing.Point(71, 59);121 this.btnNot2.Name = "btnNot2";122 this.btnNot2.Size = new System.Drawing.Size(90, 35);123 this.btnNot2.TabIndex = 17;124 this.btnNot2.Text = "2组合";125 this.btnNot2.UseVisualStyleBackColor = true;126 this.btnNot2.Click += new System.EventHandler(this.btnNot2_Click);127 // 128 // txtnot129 // 130 this.txtnot.Location = new System.Drawing.Point(85, 27);131 this.txtnot.Name = "txtnot";132 this.txtnot.Size = new System.Drawing.Size(239, 21);133 this.txtnot.TabIndex = 16;134 this.txtnot.Text = "abc012";135 // 136 // groupBox2137 // 138 this.groupBox2.Controls.Add(this.label4);139 this.groupBox2.Controls.Add(this.btnNot3);140 this.groupBox2.Controls.Add(this.btnNot2);141 this.groupBox2.Controls.Add(this.txtnot);142 this.groupBox2.Location = new System.Drawing.Point(22, 32);143 this.groupBox2.Name = "groupBox2";144 this.groupBox2.Size = new System.Drawing.Size(369, 131);145 this.groupBox2.TabIndex = 19;146 this.groupBox2.TabStop = false;147 this.groupBox2.Text = "取不重复组合";148 // 149 // groupBox1150 // 151 this.groupBox1.Controls.Add(this.groupBox2);152 this.groupBox1.Controls.Add(this.groupBox3);153 this.groupBox1.Location = new System.Drawing.Point(291, 39);154 this.groupBox1.Name = "groupBox1";155 this.groupBox1.Size = new System.Drawing.Size(416, 364);156 this.groupBox1.TabIndex = 16;157 this.groupBox1.TabStop = false;158 this.groupBox1.Text = "操作";159 // 160 // label3161 // 162 this.label3.AutoSize = true;163 this.label3.Location = new System.Drawing.Point(155, 11);164 this.label3.Name = "label3";165 this.label3.Size = new System.Drawing.Size(41, 12);166 this.label3.TabIndex = 15;167 this.label3.Text = "总数:";168 // 169 // label1170 // 171 this.label1.AutoSize = true;172 this.label1.Location = new System.Drawing.Point(24, 11);173 this.label1.Name = "label1";174 this.label1.Size = new System.Drawing.Size(65, 12);175 this.label1.TabIndex = 14;176 this.label1.Text = "显示结果:";177 // 178 // txtShow179 // 180 this.txtShow.Location = new System.Drawing.Point(26, 39);181 this.txtShow.Multiline = true;182 this.txtShow.Name = "txtShow";183 this.txtShow.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;184 this.txtShow.Size = new System.Drawing.Size(217, 364);185 this.txtShow.TabIndex = 12;186 // 187 // lbCount188 // 189 this.lbCount.AutoSize = true;190 this.lbCount.Location = new System.Drawing.Point(202, 11);191 this.lbCount.Name = "lbCount";192 this.lbCount.Size = new System.Drawing.Size(41, 12);193 this.lbCount.TabIndex = 13;194 this.lbCount.Text = "label2";195 // 196 // FrmDemo197 // 198 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);199 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;200 this.ClientSize = new System.Drawing.Size(724, 414);201 this.Controls.Add(this.groupBox1);202 this.Controls.Add(this.label3);203 this.Controls.Add(this.label1);204 this.Controls.Add(this.txtShow);205 this.Controls.Add(this.lbCount);206 this.Name = "FrmDemo";207 this.Text = "凹凸组合测试";208 this.Load += new System.EventHandler(this.FrmDemo_Load);209 this.groupBox3.ResumeLayout(false);210 this.groupBox3.PerformLayout();211 this.groupBox2.ResumeLayout(false);212 this.groupBox2.PerformLayout();213 this.groupBox1.ResumeLayout(false);214 this.ResumeLayout(false);215 this.PerformLayout();216 217 }218 219 #endregion220 221 private System.Windows.Forms.Label label5;222 private System.Windows.Forms.Button btnAll2;223 private System.Windows.Forms.Button btnAll3;224 private System.Windows.Forms.GroupBox groupBox3;225 private System.Windows.Forms.TextBox txtAll;226 private System.Windows.Forms.Label label4;227 private System.Windows.Forms.Button btnNot3;228 private System.Windows.Forms.Button btnNot2;229 private System.Windows.Forms.TextBox txtnot;230 private System.Windows.Forms.GroupBox groupBox2;231 private System.Windows.Forms.GroupBox groupBox1;232 private System.Windows.Forms.Label label3;233 private System.Windows.Forms.Label label1;234 private System.Windows.Forms.TextBox txtShow;235 private System.Windows.Forms.Label lbCount;236 }
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:组合排列的实现方法
关键词:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。