void insert_sort(int *a,int n) { if(n==1) return insert_sort(a,n-1) int temp=a[n-1] for(int i=n-2 i>=0 i--) { if(temp<a[i]) a[i+1]=a[i] else break } a[i+1]=temp }
標簽: insert_sort int return void
上傳時間: 2014-01-22
上傳用戶:banyou
詞法分析 1 試驗目的 設計,編制并調試一個此法分析程序,加深對此法分原理的理解. 2 試驗要求 1)待分析的簡單語言的詞法 * 關鍵字: begin if then while do end 所有關鍵字都是小寫. 2)運算符和界符: : = + * - / < <= <> > >= = ( ) # 3)其他單詞是標識符(ID)和整數型常數(NUM),通過一下正規式定義: ID=letter (letter|digit)* NUM=digit digit* 4)空格由空白,制表符和換行符組成,空格一般用來分隔ID,NUM,運算符,界符和關鍵字,此法分析階段通常被忽略. 3 各種單詞符號對應的種別碼如表所示
上傳時間: 2017-01-08
上傳用戶:dongqiangqiang
Instead of finding the longest common subsequence, let us try to determine the length of the LCS. Then tracking back to find the LCS. Consider a1a2…am and b1b2…bn. Case 1: am=bn. The LCS must contain am, we have to find the LCS of a1a2…am-1 and b1b2…bn-1. Case 2: am≠bn. Wehave to find the LCS of a1a2…am-1 and b1b2…bn, and a1a2…am and b b b b1b2…bn-1 Let A = a1 a2 … am and B = b1 b2 … bn Let Li j denote the length of the longest i,g g common subsequence of a1 a2 … ai and b1 b2 … bj. Li,j = Li-1,j-1 + 1 if ai=bj max{ L L } a≠b i-1,j, i,j-1 if ai≠j L0,0 = L0,j = Li,0 = 0 for 1≤i≤m, 1≤j≤n.
標簽: the subsequence determine Instead
上傳時間: 2013-12-17
上傳用戶:evil
//獲得當前的模式 oldmode = vga_getcurrentmode[] //初始化 vga_init[] //判斷是否支持該模式 if[vga_hasmode[mode]] vga_setmode[mode] else { printf["No such mode\n"] exit[1] } //取得信息 width = vga_getxdim[] height = vga_getydim[] colors = vga_getcolors[] //繪圖 for[i=0 i<colors i++]{ vga_setcolor[i] vga_drawline[0, i, width-1, i] }
標簽: vga_getcurrentmode vga_init oldmode vga_ha
上傳時間: 2014-12-19
上傳用戶:maizezhen
//獲得當前的模式 oldmode = vga_getcurrentmode[] //初始化 vga_init[] //判斷是否支持該模式 if[vga_hasmode[mode]] vga_setmode[mode] else { printf["No such mode\n"] exit[1] } //獲得當前的模式 mode = vga_getcurrentmode[] info = vga_getmodeinfo[mode]
標簽: vga_getcurrentmode vga_init oldmode vga_ha
上傳時間: 2017-03-24
上傳用戶:ecooo
Program Description: The program asks the user to choice from the menu an option A. Check to see if a number is prime. B. Count the number of vowels in a line. X. Exit the program.
標簽: Description the Program program
上傳時間: 2017-04-08
上傳用戶:磊子226
A Convex Hull is the smallest convex polygon that contains every point of the set S. A polygon P is convex if and only if, for any two points A and B inside the polygon, the line segment AB is inside P. One way to visualize a convex hull is to put a "rubber band" around all the points, and let it wrap as tight as it can. The resultant polygon is a convex hull.
上傳時間: 2013-12-23
上傳用戶:it男一枚
編譯課上做的小程序,用四種分析方法分別實現(LL1,算符優先,遞歸下降,簡單詞法分析) 完成對正則文法所描述的Pascal語言子集單詞符號的詞法分析程序。 <標識符>→字母︱ <標識符>字母︱ <標識符>數字 <無符號整數>→數字︱ <無符號整數>數字 <單字符分界符> →+ ︱- ︱* ︱ ︱(︱) <雙字符分界符>→<大于>=︱<小于>=︱<小于>>︱<冒號>=︱<斜豎>* <小于>→< <等于>→= <大于>→> <冒號> →: <斜豎> →/ 識別語言的保留字 :begin end if then else for do while and or not
上傳時間: 2014-06-29
上傳用戶:sjyy1001
P3.20. Consider an analog signal xa (t) = sin (2πt), 0 ≤t≤ 1. It is sampled at Ts = 0.01, 0.05, and 0.1 sec intervals to obtain x(n). b) Reconstruct the analog signal ya (t) from the samples x(n) using the sinc interpolation (use ∆ t = 0.001) and determine the frequency in ya (t) from your plot. (Ignore the end effects.) C) Reconstruct the analog signal ya (t) from the samples x (n) using the cubic spline interpolation and determine the frequency in ya (t) from your plot. (Ignore the end effects.)
標簽: Consider sampled analog signal
上傳時間: 2017-07-12
上傳用戶:咔樂塢
實驗目的 通過上機實習,加深對語法制導翻譯原理的理解,掌握將語法分析所識別的語法成分變換為中間代碼的語義翻譯方法. 實驗要求 采用遞歸下降語法制導翻譯法,對算術表達式、賦值語句進行語義分析并生成四元式序列。 實驗的輸入和輸出 輸入是語法分析提供的正確的單詞串,輸出為三地址指令形式的四元式序列。 例如:對于語句串 begin a:=2+3*4 x:=(a+b)/c end# 輸出的三地址指令如下: (1) t1=3*4 (2) t2=2+t1 (3) a=t2 (4) t3=a+b (5) t4=t3/c (6) x=t4
上傳時間: 2017-09-27
上傳用戶:hjshhyy