版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、<p><b> 課程設(shè)計(jì)報(bào)告</b></p><p> ——Morse電碼發(fā)聲器</p><p><b> 程序方案:</b></p><p> 0-9和A-Z的摩爾斯電碼表如下圖所示:</p><p> 將0-9和A-Z的摩爾斯電碼制作為一個(gè)36行6列的二維數(shù)組,如下圖所示&
2、lt;/p><p> 當(dāng)輸入0-9或A-Z之間的字符時(shí),程序會(huì)根絕具體的字符,從摩爾斯電碼表的二維數(shù)組中選出對(duì)應(yīng)該字符的一行數(shù)組輸出,作為該字符的摩爾斯電碼。</p><p> 用一個(gè)字節(jié)的二進(jìn)制數(shù)代表一個(gè)字符的摩爾斯電碼,左起第一個(gè)1為起始標(biāo)志(起始標(biāo)志及之前的0無(wú)效)。</p><p> 起始標(biāo)志后的0表示點(diǎn)。</p><p> 起始
3、標(biāo)志后的1表示劃。</p><p><b> 如:</b></p><p> A 的報(bào)文信息 0000 0101</p><p> B 的報(bào)文信息 0001 1000</p><p> C 的報(bào)文信息 0001 1010</p><p> 按此規(guī)律建立一個(gè)報(bào)文信息
4、表,報(bào)文信息表要按 0—9 、A—Z的順序排列,發(fā)送時(shí)先查表找字符對(duì)應(yīng)的報(bào)文信息,左移報(bào)文信息找起始標(biāo)志,(起始標(biāo)志及之前的0不發(fā)聲),然后調(diào)用點(diǎn)劃子程序發(fā)點(diǎn)劃聲響,發(fā)送一個(gè)字符循環(huán)8次則自動(dòng)結(jié)束。報(bào)文信息表同樣為一個(gè)36行6列的二維數(shù)組,如下圖所示:</p><p><b> 系統(tǒng)細(xì)節(jié)方案:</b></p><p> 點(diǎn)劃間隔子程序是通過(guò)調(diào)用window.h庫(kù)中
5、的Beep函數(shù)是系統(tǒng)發(fā)出聲音。程序收到字符后,根據(jù)字符對(duì)應(yīng)的摩爾斯電碼表中的數(shù)組,輸出該字符的摩爾斯電碼,并且查找到該字符的01報(bào)文信息表,通過(guò)兩個(gè)循環(huán),調(diào)用點(diǎn)劃子程序,完成電碼的發(fā)音功能。</p><p><b> 子程序及其流程圖:</b></p><p> 點(diǎn)聲音程序代碼:點(diǎn)聲音程序流程圖</p><p> int dot()//
6、點(diǎn)聲音</p><p><b> {</b></p><p> Beep(7000,200);</p><p><b> return 0;</b></p><p><b> }</b></p><p> 劃聲音程序代碼:劃聲音程序流程圖&l
7、t;/p><p> int dash()//劃聲音</p><p><b> {</b></p><p> Beep(7000,600);</p><p><b> return 0;</b></p><p><b> }</b></p>
8、;<p> 點(diǎn)劃之間間隔程序代碼:</p><p> int space()//電碼間隔聲音</p><p><b> {</b></p><p> Beep(0,400);</p><p><b> return 0;</b></p><p><
9、;b> }</b></p><p><b> 主程序詳解:</b></p><p> 程序設(shè)計(jì)初期,用C++編寫(xiě)了一個(gè)控制臺(tái)應(yīng)用,先編寫(xiě)了一個(gè)電碼編譯的子程序:</p><p> int tra(char c)//電碼編譯</p><p><b> {</b></p
10、><p> if(c>=48&&c<=57)</p><p><b> {</b></p><p> cout<<c<<"的摩爾斯電碼是:"<<m[c-48]<<endl;</p><p> for(i=0;i<8;
11、i++)</p><p><b> {</b></p><p> if(n[c-48][i]==1)</p><p><b> {</b></p><p><b> j=i+1;</b></p><p><b> break;<
12、/b></p><p><b> }</b></p><p><b> }</b></p><p> for(i=j;i<8;i++)</p><p><b> {</b></p><p> if(n[c-48][i]==0)<
13、;/p><p> dot();//調(diào)用響鈴點(diǎn)函數(shù)</p><p> if(n[c-48][i]==1)</p><p> dash();//調(diào)用響鈴劃函數(shù)</p><p><b> space();</b></p><p><b> }</b></p>&
14、lt;p><b> }</b></p><p> else if(c>=65&&c<=90)</p><p><b> {</b></p><p> cout<<c<<"的摩爾斯電碼是:"<<m[c-65+10]<<
15、;endl;</p><p> for(i=0;i<8;i++)</p><p><b> {</b></p><p> if(n[c-65+10][i]==1)</p><p><b> {</b></p><p><b> j=i+1;</
16、b></p><p><b> break;</b></p><p><b> }</b></p><p><b> }</b></p><p> for(i=j;i<8;i++)</p><p><b> {</b
17、></p><p> if(n[c-65+10][i]==0)</p><p><b> dot();</b></p><p> if(n[c-65+10][i]==1)</p><p><b> dash();</b></p><p><b> s
18、pace();</b></p><p><b> }</b></p><p><b> }</b></p><p> else if(c<48||(c>57&&c<65)||c>90)</p><p><b> {</b&g
19、t;</p><p> cout<<c<<"輸入格式錯(cuò)誤,不是0-9或A-Z之間的字符"<<endl;</p><p><b> }</b></p><p><b> return 0;</b></p><p><b> }&
20、lt;/b></p><p> 電碼編譯子程序流程圖:</p><p> 在主程序中利用fstream庫(kù)中的ifstream文件流又編寫(xiě)了一段可以打開(kāi)文件的語(yǔ)句,主程序代碼如下:</p><p> int main()//主程序</p><p><b> {</b></p><p>
21、<b> while(1)</b></p><p><b> {</b></p><p> cout<<"請(qǐng)選擇輸入字符或者文件路徑"<<endl;//選擇輸入字符還是文件</p><p><b> cin>>ch;</b></p&
22、gt;<p> if(ch=='c')//輸入字符進(jìn)行編括譯</p><p><b> {</b></p><p> cout<<"請(qǐng)輸入0-9或A-Z之間的字符"<<endl;</p><p><b> while(1)</b></p
23、><p><b> {</b></p><p><b> cin>>c;</b></p><p> tra(c);//調(diào)用編碼函</p><p> Sleep(500);//設(shè)置讀取字符延遲</p><p><b> }</b><
24、/p><p><b> }</b></p><p> else if(ch=='f')//輸入文件路徑進(jìn)行編譯</p><p><b> {</b></p><p> cout<<"請(qǐng)輸入文件路徑"<<endl;</p>
25、<p> string filename;</p><p> cin>>filename;</p><p> ifstream infile(filename,ios::in);</p><p> if(!infile)</p><p><b> {</b></p><
26、p> cerr<<"打開(kāi)文件錯(cuò)誤"<<endl;</p><p><b> }</b></p><p> while(infile.get(c))</p><p><b> {</b></p><p><b> tra(c);&l
27、t;/b></p><p> Sleep(500);//設(shè)置讀取字符延遲</p><p><b> }</b></p><p><b> }</b></p><p><b> else</b></p><p> cout<<&
28、quot;輸入格式錯(cuò)誤"<<endl;</p><p><b> }</b></p><p><b> }</b></p><p><b> 主程序流程圖</b></p><p><b> 編譯運(yùn)行的結(jié)果:</b></p
29、><p> 程序設(shè)計(jì)后期在windows窗體應(yīng)用中創(chuàng)建項(xiàng)目,建立一個(gè)窗體,在窗體中完成字符、文件的打開(kāi)、編譯功能,在窗體中添加控件,將之前的程序?qū)懭敫鱾€(gè)控件的動(dòng)作中,完成程序的功能,程序運(yùn)行結(jié)果如下圖:</p><p> 在textBox1中輸入字符,程序?qū)extBox1中的字符存入指向字符數(shù)組的指針中,再根絕數(shù)組中字符,找到相對(duì)應(yīng)的報(bào)文信息進(jìn)行編譯發(fā)聲。</p><
30、p> 利用openFileDialog打開(kāi)文件,利用richTextBox中的LoadFile方法加載文件,再將richTextBox中的字符存入數(shù)組指針中,利用指針循環(huán)自加對(duì)數(shù)組指針中的字符進(jìn)行編譯發(fā)聲。</p><p> Morse電碼主程序自動(dòng)生成的cpp:</p><p> // morse.cpp: 主項(xiàng)目文件</p><p> #inclu
31、de "stdafx.h"</p><p> #include "Form1.h"</p><p> using namespace morse;</p><p> [STAThreadAttribute]</p><p> int main(array<System::String ^&
32、gt; ^args)</p><p><b> {</b></p><p> // 在創(chuàng)建任何控件之前啟用 Windows XP 可視化效果</p><p> Application::EnableVisualStyles();</p><p> Application::SetCompatibleTextRen
33、deringDefault(false); </p><p> // 創(chuàng)建主窗口并運(yùn)行它</p><p> Application::Run(gcnew Form1());</p><p><b> return 0;</b></p><p><b> }</b></p>&l
34、t;p> Form1.h庫(kù)中的源代碼:</p><p> #pragma once</p><p> #include<Windows.h></p><p> namespace morse {</p><p> using namespace System;</p><p> using
35、 namespace System::ComponentModel;</p><p> using namespace System::Collections;</p><p> using namespace System::Windows::Forms;</p><p> using namespace System::Data;</p>&
36、lt;p> using namespace System::Drawing;</p><p> using namespace System::Runtime::InteropServices;</p><p> /// <summary></p><p> /// Form1 摘要</p><p> /// &l
37、t;/summary></p><p> public ref class Form1 : public System::Windows::Forms::Form</p><p><b> {</b></p><p><b> public:</b></p><p> Form1(vo
38、id)</p><p><b> {</b></p><p> InitializeComponent();</p><p><b> //</b></p><p> //TODO: 在此處添加構(gòu)造函數(shù)代碼</p><p><b> //</b>
39、;</p><p><b> }</b></p><p> protected:</p><p> /// <summary></p><p> /// 清理所有正在使用的資源</p><p> /// </summary></p><p>
40、;<b> ~Form1()</b></p><p><b> {</b></p><p> if (components)</p><p><b> {</b></p><p> delete components;</p><p><
41、b> }</b></p><p><b> }</b></p><p> private: System::Windows::Forms::Label^ label1;</p><p> protected: </p><p> private: System::Windows::Forms
42、::TextBox^ textBox1;</p><p> private: System::Windows::Forms::ListBox^ listBox1;</p><p> private: System::Windows::Forms::Button^ button1;</p><p> private: System::Windows::Fo
43、rms::Label^ label3;</p><p> private: System::Windows::Forms::Label^ label4;</p><p> private: System::Windows::Forms::OpenFileDialog^ openFileDialog1;</p><p> private: System::
44、Windows::Forms::RichTextBox^ richTextBox1;</p><p> private: System::Windows::Forms::Button^ button3;</p><p> private: System::Windows::Forms::Label^ label2;</p><p> private: S
45、ystem::Windows::Forms::Label^ label5;</p><p> private: System::Windows::Forms::Button^ button4;</p><p> private: System::Windows::Forms::Button^ button6;</p><p> private: Syst
46、em::Windows::Forms::Button^ button2;</p><p><b> private:</b></p><p> /// <summary></p><p> /// 必需的設(shè)計(jì)器變量</p><p> /// </summary></p>&
47、lt;p> System::ComponentModel::Container ^components;</p><p> #pragma region Windows Form Designer generated code</p><p> /// <summary></p><p> /// 設(shè)計(jì)器支持所需的方法不要</p>
48、;<p> /// 使用代碼編輯器修改此方法的內(nèi)容</p><p> /// </summary></p><p> void InitializeComponent(void)</p><p><b> {</b></p><p> this->label1 = (gcnew
49、System::Windows::Forms::Label());</p><p> this->textBox1 = (gcnew System::Windows::Forms::TextBox());</p><p> this->listBox1 = (gcnew System::Windows::Forms::ListBox());</p><p
50、> this->button1 = (gcnew System::Windows::Forms::Button());</p><p> this->label3 = (gcnew System::Windows::Forms::Label());</p><p> this->label4 = (gcnew System::Windows::Forms::L
51、abel());</p><p> this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());</p><p> this->richTextBox1 = (gcnew System::Windows::Forms::RichTextBox());</p><p>
52、; this->button3 = (gcnew System::Windows::Forms::Button());</p><p> this->label2 = (gcnew System::Windows::Forms::Label());</p><p> this->label5 = (gcnew System::Windows::Forms::Labe
53、l());</p><p> this->button4 = (gcnew System::Windows::Forms::Button());</p><p> this->button6 = (gcnew System::Windows::Forms::Button());</p><p> this->button2 = (gcnew
54、System::Windows::Forms::Button());</p><p> this->SuspendLayout();</p><p><b> // </b></p><p><b> // label1</b></p><p><b> // </b&
55、gt;</p><p> this->label1->AutoSize = true;</p><p> this->label1->Location = System::Drawing::Point(51, 32);</p><p> this->label1->Name = L"label1";<
56、;/p><p> this->label1->Size = System::Drawing::Size(65, 12);</p><p> this->label1->TabIndex = 0;</p><p> this->label1->Text = L"請(qǐng)輸入字符";</p><p&
57、gt;<b> // </b></p><p> // textBox1</p><p><b> // </b></p><p> this->textBox1->Location = System::Drawing::Point(53, 49);</p><p> this
58、->textBox1->Name = L"textBox1";</p><p> this->textBox1->Size = System::Drawing::Size(100, 21);</p><p> this->textBox1->TabIndex = 1;</p><p> this->
59、textBox1->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &Form1::textBox1_KeyDown);</p><p><b> // </b></p><p> // listBox1</p><p><b> //
60、</b></p><p> this->listBox1->FormattingEnabled = true;</p><p> this->listBox1->ItemHeight = 12;</p><p> this->listBox1->Location = System::Drawing::Point(
61、315, 55);</p><p> this->listBox1->Name = L"listBox1";</p><p> this->listBox1->Size = System::Drawing::Size(120, 184);</p><p> this->listBox1->TabIndex
62、 = 2;</p><p><b> // </b></p><p> // button1</p><p><b> // </b></p><p> this->button1->Location = System::Drawing::Point(67, 132);</
63、p><p> this->button1->Name = L"button1";</p><p> this->button1->Size = System::Drawing::Size(75, 23);</p><p> this->button1->TabIndex = 4;</p><
64、;p> this->button1->Text = L"發(fā)聲";</p><p> this->button1->UseVisualStyleBackColor = true;</p><p> this->button1->MouseClick += gcnew System::Windows::Forms::Mouse
65、EventHandler(this, &Form1::button1_MouseClick);</p><p><b> // </b></p><p><b> // label3</b></p><p><b> // </b></p><p> this-
66、>label3->AutoSize = true;</p><p> this->label3->Location = System::Drawing::Point(53, 95);</p><p> this->label3->Name = L"label3";</p><p> this->la
67、bel3->Size = System::Drawing::Size(89, 12);</p><p> this->label3->TabIndex = 6;</p><p> this->label3->Text = L"輸入的字符是:";</p><p><b> // </b>&l
68、t;/p><p><b> // label4</b></p><p><b> // </b></p><p> this->label4->AutoSize = true;</p><p> this->label4->Location = System::Drawi
69、ng::Point(138, 95);</p><p> this->label4->Name = L"label4";</p><p> this->label4->Size = System::Drawing::Size(0, 12);</p><p> this->label4->TabIndex
70、= 7;</p><p><b> // </b></p><p> // openFileDialog1</p><p><b> // </b></p><p> this->openFileDialog1->FileName = L"openFileDialog1
71、";</p><p><b> // </b></p><p> // richTextBox1</p><p><b> // </b></p><p> this->richTextBox1->Location = System::Drawing::Point(12
72、, 256);</p><p> this->richTextBox1->Name = L"richTextBox1";</p><p> this->richTextBox1->Size = System::Drawing::Size(213, 132);</p><p> this->richTextBox
73、1->TabIndex = 8;</p><p> this->richTextBox1->Text = L"";</p><p><b> // </b></p><p> // button3</p><p><b> // </b></p&g
74、t;<p> this->button3->Location = System::Drawing::Point(315, 256);</p><p> this->button3->Name = L"button3";</p><p> this->button3->Size = System::Drawing::
75、Size(74, 25);</p><p> this->button3->TabIndex = 9;</p><p> this->button3->Text = L"打開(kāi)文件";</p><p> this->button3->UseVisualStyleBackColor = true;</p
76、><p> this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);</p><p><b> // </b></p><p><b> // label2</b></p><p
77、><b> // </b></p><p> this->label2->AutoSize = true;</p><p> this->label2->Location = System::Drawing::Point(313, 32);</p><p> this->label2->Name
78、 = L"label2";</p><p> this->label2->Size = System::Drawing::Size(29, 12);</p><p> this->label2->TabIndex = 11;</p><p> this->label2->Text = L"編碼&
79、quot;;</p><p><b> // </b></p><p><b> // label5</b></p><p><b> // </b></p><p> this->label5->AutoSize = true;</p>&l
80、t;p> this->label5->Location = System::Drawing::Point(55, 238);</p><p> this->label5->Name = L"label5";</p><p> this->label5->Size = System::Drawing::Size(0, 12)
81、;</p><p> this->label5->TabIndex = 12;</p><p><b> // </b></p><p> // button4</p><p><b> // </b></p><p> this->button4
82、->Location = System::Drawing::Point(315, 312);</p><p> this->button4->Name = L"button4";</p><p> this->button4->Size = System::Drawing::Size(75, 23);</p><p&
83、gt; this->button4->TabIndex = 13;</p><p> this->button4->Text = L"編碼";</p><p> this->button4->UseVisualStyleBackColor = true;</p><p> this->button
84、4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);</p><p><b> // </b></p><p> // button6</p><p><b> // </b></p><p>
85、 this->button6->Location = System::Drawing::Point(315, 364);</p><p> this->button6->Name = L"button6";</p><p> this->button6->Size = System::Drawing::Size(75, 23);&
86、lt;/p><p> this->button6->TabIndex = 15;</p><p> this->button6->Text = L"發(fā)聲";</p><p> this->button6->UseVisualStyleBackColor = true;</p><p>
87、 this->button6->Click += gcnew System::EventHandler(this, &Form1::button6_Click);</p><p><b> // </b></p><p> // button2</p><p><b> // </b></
88、p><p> this->button2->Location = System::Drawing::Point(453, 55);</p><p> this->button2->Name = L"button2";</p><p> this->button2->Size = System::Drawing
89、::Size(75, 23);</p><p> this->button2->TabIndex = 16;</p><p> this->button2->Text = L"清空";</p><p> this->button2->UseVisualStyleBackColor = true;</
90、p><p> this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);</p><p><b> // </b></p><p><b> // Form1</b></p><p
91、><b> // </b></p><p> this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);</p><p> this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;</p><
92、p> this->ClientSize = System::Drawing::Size(539, 416);</p><p> this->Controls->Add(this->button2);</p><p> this->Controls->Add(this->button6);</p><p> th
93、is->Controls->Add(this->button4);</p><p> this->Controls->Add(this->label5);</p><p> this->Controls->Add(this->label2);</p><p> this->Controls->A
94、dd(this->button3);</p><p> this->Controls->Add(this->richTextBox1);</p><p> this->Controls->Add(this->label4);</p><p> this->Controls->Add(this->lab
95、el3);</p><p> this->Controls->Add(this->button1);</p><p> this->Controls->Add(this->listBox1);</p><p> this->Controls->Add(this->textBox1);</p>
96、<p> this->Controls->Add(this->label1);</p><p> this->Name = L"Form1";</p><p> this->Text = L"摩爾斯電碼發(fā)聲器";</p><p> this->ResumeLayout(fa
97、lse);</p><p> this->PerformLayout();</p><p><b> }</b></p><p> #pragma endregion</p><p> int dot()//點(diǎn)聲音</p><p><b> {</b><
98、/p><p> Beep(7000,200);</p><p><b> return 0;</b></p><p><b> }</b></p><p> int dash()//劃聲音</p><p><b> {</b></p>
99、<p> Beep(7000,600);</p><p><b> return 0;</b></p><p><b> }</b></p><p> int space()//電碼間隔聲音</p><p><b> {</b></p>&l
100、t;p> Beep(0,400);</p><p><b> return 0;</b></p><p><b> }</b></p><p> private: System::Void textBox1_KeyDown(System::Object^ sender, System::Windows::F
101、orms::KeyEventArgs^ e) //輸入字符進(jìn)行編碼</p><p><b> {</b></p><p> const char m[36][6]=//摩爾斯電碼表括</p><p><b> {</b></p><p> {"-----"},{&quo
102、t;.----"},{"..---"},{"...--"},{"....-"},{"....."},</p><p> {"-...."},{"--..."},{"---.."},{"----."},{".-"},{&quo
103、t;-..."},</p><p> {"-.-."},{"-.."},{"."},{"..-."},{"--."},{"...."},</p><p> {".."},{".---"},{"-.-"
104、;},{".-.."},{"--"},{"-."},</p><p> {"---"},{".--."},{"--.-"},{".-."},{"..."},{"-"},</p><p> {"..-
105、"},{"...-"},{".--"},{"-..-"},{"-.--"},{"--.."}</p><p><b> };</b></p><p> if(e->KeyCode==Keys::Enter)</p><p>&
106、lt;b> {</b></p><p> label4->Text=textBox1->Text;</p><p> for(char* ch=(char*)(void*)Marshal::StringToHGlobalAnsi(textBox1->Text);*ch;ch++)</p><p><b> {&l
107、t;/b></p><p> if(*ch>=48&&*ch<=57)</p><p> listBox1->Items->Add(gcnew String(m[*ch-48]));</p><p> else if(*ch>=65&&*ch<=90)</p><p&
108、gt; listBox1->Items->Add(gcnew String(m[*ch-65+10]));</p><p><b> else</b></p><p> listBox1->Items->Add("字符格式錯(cuò)誤");</p><p><b> }</b>&
109、lt;/p><p><b> }</b></p><p><b> };</b></p><p> private: System::Void button1_MouseClick(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) /
110、/輸入字符發(fā)出電碼聲</p><p><b> {</b></p><p> const int n[36][8]=//報(bào)文消息表</p><p><b> {</b></p><p> {0,0,1,1,1,1,1,1},{0,0,1,0,1,1,1,1},{0,0,1,0,0,1,1,1
111、},{0,0,1,0,0,0,1,1},{0,0,1,0,0,0,0,1},{0,0,1,0,0,0,0,0},</p><p> {0,0,1,1,0,0,0,0},{0,0,1,1,1,0,0,0},{0,0,1,1,1,1,0,0},{0,0,1,1,1,1,1,0},{0,0,0,0,0,1,0,1},{0,0,0,1,1,0,0,0},</p><p> {0,0,0,1,1
112、,0,1,0},{0,0,0,0,1,1,0,0},{0,0,0,0,0,0,1,0},{0,0,0,1,0,0,1,0},{0,0,0,0,1,1,1,0},{0,0,0,1,0,0,0,0},</p><p> {0,0,0,0,0,1,0,0},{0,0,0,1,0,1,1,1},{0,0,0,0,1,1,0,1},{0,0,0,1,0,1,0,0},{0,0,0,0,0,1,1,1},{0,0,0,0,
113、0,1,1,0},</p><p> {0,0,0,0,1,1,1,1},{0,0,0,1,0,1,1,0},{0,0,0,1,1,1,0,1},{0,0,0,0,1,0,1,0},{0,0,0,0,1,0,0,0},{0,0,0,0,0,0,1,1},</p><p> {0,0,0,0,1,0,0,1},{0,0,0,1,0,0,0,1},{0,0,0,0,1,0,1,1},{0,
114、0,0,1,1,0,0,1},{0,0,0,1,1,0,1,1},{0,0,0,1,1,1,0,0}</p><p><b> };</b></p><p> for(char* ch=(char*)(void*)Marshal::StringToHGlobalAnsi(textBox1->Text);*ch;ch++)</p><p&g
115、t;<b> {</b></p><p> if(*ch>=48&&*ch<=57)</p><p><b> {</b></p><p><b> int i,j;</b></p><p> for(i=0;i<8;i++)<
116、/p><p><b> {</b></p><p> if(n[*ch-48][i]==1)</p><p><b> {</b></p><p><b> j=i+1;</b></p><p><b> break;</b>
117、</p><p><b> }</b></p><p><b> }</b></p><p> for(i=j;i<8;i++)</p><p><b> {</b></p><p> if(n[*ch-48][i]==0)</p&
118、gt;<p> dot();//調(diào)用響鈴點(diǎn)函</p><p> if(n[*ch-48][i]==1)</p><p> dash();//調(diào)用響鈴劃函</p><p><b> space();</b></p><p><b> }</b></p><p
119、><b> }</b></p><p> else if(*ch>=65&&*ch<=90)</p><p><b> {</b></p><p><b> int i,j;</b></p><p> for(i=0;i<8;i
120、++)</p><p><b> {</b></p><p> if(n[*ch-65+10][i]==1)</p><p><b> {</b></p><p><b> j=i+1;</b></p><p><b> break;
121、</b></p><p><b> }</b></p><p><b> }</b></p><p> for(i=j;i<8;i++)</p><p><b> {</b></p><p> if(n[*ch-65+10][
122、i]==0)</p><p> dot();//調(diào)用響鈴點(diǎn)函數(shù)</p><p> if(n[*ch-65+10][i]==1)</p><p> dash();//調(diào)用響鈴劃函數(shù)</p><p><b> space();</b></p><p><b> }</b>
123、;</p><p><b> }</b></p><p> Sleep(300);</p><p><b> }</b></p><p><b> }</b></p><p> private: System::Void button3_Cli
124、ck(System::Object^ sender, System::EventArgs^ e) //輸入文件打開(kāi)</p><p><b> {</b></p><p> System::Windows::Forms::DialogResult dlg;</p><p> openFileDialog1->InitialDire
125、ctory="d:\\";//設(shè)置打開(kāi)文件初始路徑</p><p> openFileDialog1->Filter="寫(xiě)字板文件t(*.rtf)|*.rtf";</p><p> openFileDialog1->RestoreDirectory= true;</p><p> dlg=openFileDi
126、alog1->ShowDialog();</p><p><b> try</b></p><p><b> {</b></p><p> if(dlg==System::Windows::Forms::DialogResult::OK)</p><p><b> {<
127、/b></p><p> this->richTextBox1->LoadFile(openFileDialog1->FileName,RichTextBoxStreamType::RichText);</p><p> String^f=openFileDialog1->FileName;</p><p> label5->
128、;Text=f;</p><p><b> }</b></p><p><b> }</b></p><p> catch(System::ArgumentException^e)</p><p><b> {</b></p><p> Mes
129、sageBox::Show(L"選擇的不是rtf格式的文件!無(wú)效");</p><p><b> }</b></p><p><b> }</b></p><p> private: System::Void button4_Click(System::Object^ sender, Syste
130、m::EventArgs^ e) //對(duì)文件內(nèi)容進(jìn)行編碼</p><p><b> {</b></p><p> const char m[36][6]=//摩爾斯電碼表</p><p><b> {</b></p><p> {"-----"},{".---
131、-"},{"..---"},{"...--"},{"....-"},{"....."},</p><p> {"-...."},{"--..."},{"---.."},{"----."},{".-"},{"-...
132、"},</p><p> {"-.-."},{"-.."},{"."},{"..-."},{"--."},{"...."},</p><p> {".."},{".---"},{"-.-"},{&q
133、uot;.-.."},{"--"},{"-."},</p><p> {"---"},{".--."},{"--.-"},{".-."},{"..."},{"-"},</p><p> {"..-"
134、},{"...-"},{".--"},{"-..-"},{"-.--"},{"--.."}</p><p><b> };</b></p><p> for(char* ch=(char*)(void*)Marshal::StringToHGlobalAnsi(ri
135、chTextBox1->Text);*ch;ch++)</p><p><b> {</b></p><p> if(*ch>=48&&*ch<=57)</p><p> listBox1->Items->Add(gcnew String(m[*ch-48]));</p><
136、;p> else if(*ch>=65&&*ch<=90)</p><p> listBox1->Items->Add(gcnew String(m[*ch-65+10]));</p><p><b> else</b></p><p> listBox1->Items->Add
137、("字符格式錯(cuò)誤");</p><p><b> }</b></p><p><b> }</b></p><p> private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) //對(duì)文件內(nèi)
138、容發(fā)出電碼聲響</p><p><b> {</b></p><p> const int n[36][8]=//報(bào)饋文消息表</p><p><b> {</b></p><p> {0,0,1,1,1,1,1,1},{0,0,1,0,1,1,1,1},{0,0,1,0,0,1,1,1},
139、{0,0,1,0,0,0,1,1},{0,0,1,0,0,0,0,1},{0,0,1,0,0,0,0,0},</p><p> {0,0,1,1,0,0,0,0},{0,0,1,1,1,0,0,0},{0,0,1,1,1,1,0,0},{0,0,1,1,1,1,1,0},{0,0,0,0,0,1,0,1},{0,0,0,1,1,0,0,0},</p><p> {0,0,0,1,1,0
140、,1,0},{0,0,0,0,1,1,0,0},{0,0,0,0,0,0,1,0},{0,0,0,1,0,0,1,0},{0,0,0,0,1,1,1,0},{0,0,0,1,0,0,0,0},</p><p> {0,0,0,0,0,1,0,0},{0,0,0,1,0,1,1,1},{0,0,0,0,1,1,0,1},{0,0,0,1,0,1,0,0},{0,0,0,0,0,1,1,1},{0,0,0,0,0,
141、1,1,0},</p><p> {0,0,0,0,1,1,1,1},{0,0,0,1,0,1,1,0},{0,0,0,1,1,1,0,1},{0,0,0,0,1,0,1,0},{0,0,0,0,1,0,0,0},{0,0,0,0,0,0,1,1},</p><p> {0,0,0,0,1,0,0,1},{0,0,0,1,0,0,0,1},{0,0,0,0,1,0,1,1},{0,0,
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫(kù)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 24516.河北常見(jiàn)螽斯與蟋蟀鳴聲與發(fā)聲器結(jié)構(gòu)
- 唇讀發(fā)聲器中視覺(jué)信息的檢測(cè)與處理.pdf
- 次聲活塞發(fā)聲器機(jī)理及相關(guān)技術(shù)研究.pdf
- 莫爾斯電碼
- 巴特沃斯濾波器課程設(shè)計(jì)
- 巴特沃斯濾波器課程設(shè)計(jì)
- 發(fā)聲器官的機(jī)能與運(yùn)用.pdf
- 斯沃斯摩爾學(xué)院
- 時(shí)序比較器課程設(shè)計(jì)報(bào)告
- 計(jì)算器課程設(shè)計(jì)報(bào)告
- 課程設(shè)計(jì)報(bào)告---計(jì)算器設(shè)計(jì)
- 競(jìng)賽搶答器課程設(shè)計(jì)-微機(jī)接口課程設(shè)計(jì)報(bào)告
- 變頻器課程設(shè)計(jì)報(bào)告
- 競(jìng)賽搶答器課程設(shè)計(jì)-微機(jī)接口課程設(shè)計(jì)報(bào)告
- 巴特沃斯數(shù)字低通濾波器課程設(shè)計(jì)
- 中文莫爾斯電碼表
- 中文莫爾斯電碼表
- 課程設(shè)計(jì)--8位計(jì)數(shù)器eda課程設(shè)計(jì)報(bào)告
- 石墨烯大規(guī)模機(jī)械剝離制備和石墨烯高性能發(fā)聲器.pdf
- 全喉切除食管音助發(fā)聲器發(fā)音的客觀聲學(xué)分析.pdf
評(píng)論
0/150
提交評(píng)論