C++完美演繹 經典算法 如 /* 頭文件:my_Include.h */ #include <stdio.h> /* 展開C語言的內建函數指令 */ #define PI 3.1415926 /* 宏常量,在稍后章節再詳解 */ #define circle(radius) (PI*radius*radius) /* 宏函數,圓的面積 */ /* 將比較數值大小的函數寫在自編include文件內 */ int show_big_or_small (int a,int b,int c) { int tmp if (a>b) { tmp = a a = b b = tmp } if (b>c) { tmp = b b = c c = tmp } if (a>b) { tmp = a a = b b = tmp } printf("由小至大排序之后的結果:%d %d %d\n", a, b, c) } 程序執行結果: 由小至大排序之后的結果:1 2 3 可將內建函數的include文件展開在自編的include文件中 圓圈的面積是=201.0619264
魔王語言解釋
[問題描述]
有一個魔王總是使用自己的一種非常精練而又抽象的語言講話,沒有人能聽得懂,但他的語言是可以逐步解釋成人能聽懂的語言,因為他的語言是由以下兩種形式的規則由人的語言逐步抽象上去的:
(1) α 轉換為 β1β2…βm
(2) (θδ1δ2…δn) 轉換為 θδnθδn-1… θδ1θ
在這兩種形式重,從左到右均表示解釋。試寫一個魔王語言的解釋兄,把他的話解釋成人能聽得懂的話。
[基本要求]
用下述兩條具體規則和上述規則形式(2)實現。設大寫字母表示魔王語言的詞匯;小寫字母表示人的語言詞匯;希臘字母表示可以用大寫字母或小寫字母代換的變量。魔王語言可含人的詞匯。
(1)B 轉換為 tAdA
(2)A 轉換為 sae
[測試數據]
B(exnxgz)B解釋成tsaedsaeezegexenehetsaedsae
若將小寫字母與漢字建立下表所示的對應關系,則魔王說的話是:“天上一只鵝地上一只鵝鵝追鵝趕鵝下鵝蛋鵝恨鵝天上一直鵝地上一只鵝”。
t d s a e z g x n h
天 地 上 一只 鵝 追 趕 下 蛋 恨
his project was built and tested with WinAVR-20060125.
Make sure the MCU target define in the Makefiles corresponds to the AVR you are using!!
To build the code, just install WinAVR and run "make" from the console in echomaster and
echoslave subdirs.
"make program" will program the device if you have a AVRISP attached.
Remember to set the AVR device to at least 8MHz. The AVR may use the programmable clock
from MC1319x, just remember to check if the MC1319x and SPI communication is working FIRST!
Otherwise you wont get any clock signal to the AVR and then you can t program it or reset
the fuses!
The MC1319x has default clock output of 32kHz so you will have to set your programmer to
a very low frequency (<=32kHz/4) to be able to program it while it is running on that!
This code was used for making the practical measurements in section 2.3 of my thesis. This Matlab code allows an OFDM signal to be generated based on an input data file. The data can be random data, a grey scale image, a wave file, or any type of file. The generated OFDM signal is stored as a windows wave file, allowing it to be viewed, listened to and manipulated in other programs. The modified wave file can then be decoded by the receiver software to extract the original data. This code was developed for the experiments that I performed in my honours thesis, and thus has not been fully debugged.
This is the original code developed for the thesis and so has several problems with it. The BER performance given by the simulations is infact Symbol Error Rate.
[輸入]
圖的頂點個數N,圖中頂點之間的關系及起點A和終點B
[輸出]
若A到B無路徑,則輸出“There is no path” 否則輸出A到B路徑上個頂點
[存儲結構]
圖采用鄰接矩陣的方式存儲。
[算法的基本思想]
采用廣度優先搜索的方法,從頂點A開始,依次訪問與A鄰接的頂點VA1,VA2,...,VAK, 訪問遍之后,若沒有訪問B,則繼續訪問與VA1鄰接的頂點VA11,VA12,...,VA1M,再訪問與VA2鄰接頂點...,如此下去,直至找到B,最先到達B點的路徑,一定是邊數最少的路徑。實現時采用隊列記錄被訪問過的頂點。每次訪問與隊頭頂點相鄰接的頂點,然后將隊頭頂點從隊列中刪去。若隊空,則說明到不存在通路。在訪問頂點過程中,每次把當前頂點的序號作為與其鄰接的未訪問的頂點的前驅頂點記錄下來,以便輸出時回溯。
#include<stdio.h>
int number //隊列類型
typedef struct{
int q[20]
用Fourier變換求取信號的功率譜---周期圖法
用Fourier變換求取信號的功率譜---分段周期圖法
用Fourier變換求取信號的功率譜---welch方法
功率譜估計----多窗口法(multitaper method ,MTM法)
功率譜估計----最大熵法(maxmum entmpy method,MEM法)
功率譜估計----多信號分類法(multiple signal classification,music法)Fourier transform to strike a signal to the power spectrum - the cycle of plans
Fourier transform to strike a signal to the power spectrum - Sub-cycle Method
Fourier transform to strike a signal to the power spectrum --- welch method
Power spectrum estimated more than window ---- Law (multitaper method, MTM)
---- Power spectrum estimate of maximum entropy (maxmum entmpy method, MEM)
---- More than the estimated power spectrum signal classification (multiple signal classification, music)