题目:不详细
来源:互联网 发布:cms集中管理软件 编辑:程序博客网 时间:2024/05/16 04:50
有字符串如"ABCD,BDAC,DRF,FRD,CADB,CAADB,XB",要将其中由相同字符组成的词归在一起,如果没有和其由相同字符组成的词则去掉,如上的结果为:
组1:ABCD,BDAC,CADB
组2: DRF,FRD
另外,CAADB和XB去掉
请写出代码(c#),思路和选择所使用的数据结构的原因
实现代码:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button button1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.ItemHeight = 12;
this.listBox1.Location = new System.Drawing.Point(32, 16);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(120, 316);
this.listBox1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(48, 344);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "关闭";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(200, 390);
this.Controls.Add(this.button1);
this.Controls.Add(this.listBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.fullStrName();
this.Def();
}
private string[] strName;
private void fullStrName()
{
strName = new string[7];
strName[0]="abcd";
strName[1]="dbca";
strName[2]="drf";
strName[3]="frd";
strName[4]="cadb";
strName[5]="caadb";
strName[6]="xb";
}
private void Def()
{
int i=0;
int e=1;
string StrNameCopy="";
for(int j=0;j<this.strName.Length ;j++)
{
i=1;
if(this.strName[j]=="")
{
}
else
{
StrNameCopy=this.strName[j];
char[] CH=this.strName[j].ToCharArray();
char[] SM;
for(int n=j+1;n<this.strName.Length;n++)
{
int m=0;
SM=this.strName[n].ToCharArray();
if(CH.Length ==SM.Length)
{
for(int q=0;q<CH.Length ;q++)
{
for(int a=0;a<SM.Length;a++)
{
if(CH[q].ToString()==SM[a].ToString())
{
m++;
}
}
}
}
if(m==CH.Length)
{
if(i==1)
{
StrNameCopy+=",";
}
StrNameCopy+=this.strName[n];
this.strName[n]="";
}
}
if(StrNameCopy.ToString().Split(',').Length>1)
{
this.listBox1.Items.Add("组"+e.ToString()+":"+ StrNameCopy);
e++;
}
}
}
}
}
}
- 题目:不详细
- hdu 题目分类(详细不详细!)
- hduoj题目详细分类
- 不知道题目
- hdu 题目分类 比较详细
- zoj题目分类详细的
- 详细分析.net 反序题目
- 不知道啥题目(ZT)
- poj题目详细分类及算法推荐题目
- C++数据结构精要+题目答案(详细)
- 杭电acm题目分类 非常详细
- 手机不输出详细日志
- 题目1434:今年暑假不AC 题目22
- 我知道我想不出题目
- 题目22:今年暑假不AC
- 题目1434:今年暑假不AC
- 题目1434:今年暑假不AC
- 还不知道是哪里的题目。。
- C/C++笔试、面试题目大汇总[转]
- 视窗下MySQL的启动和连接(图文)
- Web2.0专家解读未来轨迹:微软历史再现
- .net下应用javascript
- [转]线程本地存储 (TLS)
- 题目:不详细
- 在Asp.net 1.0中,CryStal Reports(水晶报表)的打包与部署问题
- sql优化之我见
- ORACLE网络的几个重点概念
- “敏捷西安”首次技术交流活动成功举行
- 好书征集译者!
- 用户如何有效地利用数据字典
- MFC文件浏览程序中改变文件读写对话框样式
- JSP连接Access数据库