資源簡介
成語接龍C#代碼以前寫的,暫時放這里,需要優化。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.IO;
namespace?Idiom
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?Idioms?Idioms;
????????private?int?maxLength?=?0;
????????private?int?oldLength?=?0;
????????//?private?List>?Dragons?=?new?List>();
????????List?maxDragon?=?new?List();
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????Idioms?=?new?Idioms();
????????????//?ReadFile();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????this.timer1.Start();
????????????string?str?=?this.textBox1.Text;
????????????char?lastChar?=?str.Substring(str.Length?-?1).ToCharArray()[0];
????????????short?Head?=?(short)((int)lastChar?-?short.MaxValue);
????????????maxLength?=?0;
????????????oldLength?=?0;
????????????this.richTextBox1.Text?=?““;
????????????if?(Idioms.IdiomHeads.ContainsKey(Head))
????????????{
????????????????//第一個龍
????????????????List?idiomList?=?Idioms.IdiomHeads[Head];
????????????????foreach?(theIdiom?idiom?in?idiomList)
????????????????{
????????????????????List?Dragon?=?new?List();
????????????????????Dragon.Add(idiom.Id);
????????????????????makeDragons(Dragon);
????????????????}
????????????}
????????????else
????????????{
????????????????MessageBox.Show(“不存在可接成語!“);
????????????????return;
????????????}
????????????this.timer1.Stop();
????????}
?
????????private?void?makeDragons(List?Dragon)
????????{
????????????short?last?=?Dragon[Dragon.Count?-?1];
????????????theIdiom?theIdiom?=?Idioms.TotalIdioms[last];
????????????short?Head?=?theIdiom.T;
????????????if?(Idioms.IdiomHeads.ContainsKey(Head))
????????????{
????????????????List?idiomList?=?Idioms.IdiomHeads[Head];
????????????????foreach?(theIdiom?idiom?in?idiomList)
????????????????{
????????????????????short?newid?=?idiom.Id;
????????????????????//如果無環就添加;
????????????????????if?(!Dragon.Contains(newid))
????????????????????{
????????????????????????List?newdragon?=?new?List(Dragon);
????????????????????????newdragon.Add(idiom.Id);
????????????????????????if?(newdragon.Count?>?maxLength)
????????????????????????{
????????????????????????????maxLength?=?newdragon.Count;
????????????????????????????maxDragon?=?newdragon;
????????????????????????????this.label1.Text?=?maxLength.ToString();
????????????????????????????this.label1.Refresh();
????????????????????????}
????????????????????????//遞歸
????????????????????????Application.DoEvents();
????????????????????????makeDragons(newdragon);
????????????????????}
????????????????}
????????????}
????????}
????????private?string?showDr
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????1603121??2007-11-02?01:23??Idiom\Idiom\bin\Debug\1.txt
?????文件???????5057??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\001.txt
?????文件???????2051??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\002.txt
?????文件???????4427??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\003.txt
?????文件??????86247??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\004.txt
?????文件??????35008??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\005.txt
?????文件?????202909??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\006.txt
?????文件?????173091??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\007.txt
?????文件??????66866??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\008.txt
?????文件???????5111??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\009.txt
?????文件??????49268??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\010.txt
?????文件??????48677??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\011.txt
?????文件??????59885??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\012.txt
?????文件??????83961??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\013.txt
?????文件??????18001??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\014.txt
?????文件??????56667??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\015.txt
?????文件??????46281??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\016.txt
?????文件??????19140??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\017.txt
?????文件????????927??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\018.txt
?????文件??????25315??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\019.txt
?????文件??????69307??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\020.txt
?????文件??????31614??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\021.txt
?????文件?????108668??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\022.txt
?????文件??????51053??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\023.txt
?????文件??????56308??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\024.txt
?????文件??????62732??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\025.txt
?????文件?????156487??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\026.txt
?????文件??????79803??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\027.txt
?????文件??????20557??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\028.txt
?????文件???????1594??2007-08-28?22:44??Idiom\Idiom\bin\Debug\Idiom\029.txt
............此處省略46個文件信息
- 上一篇:C#超級通信調試工具源碼20130916
- 下一篇:C#圖書管理系統三層架構
評論
共有 條評論