1) Write a function reverse(A) which takes a matrix A of arbitrary dimensions as input and returns a matrix B consisting of the columns of A in reverse order. Thus for example, if
A = 1 2 3 then B = 3 2 1
4 5 6 6 5 4
7 8 9 9 8 7
Write a main program to call reverse(A) for the matrix A = magic(5). Print to the screen both A and reverse(A).
2) Write a program which accepts an input k from the keyboard, and which prints out the smallest fibonacci number that is at least as large as k. The program should also print out its position in the fibonacci sequence. Here is a sample of input and output:
Enter k>0: 100
144 is the smallest fibonacci number greater than or equal to 100.
It is the 12th fibonacci number.
詞法分析器的實(shí)現(xiàn),1) 輸入:字符串(待進(jìn)行詞法分析的源程序),輸出:由(種別碼,自身值)所組成的二元組序列。
2) 功能:
a. 濾空格
b. 識(shí)別保留字
c. 識(shí)別標(biāo)識(shí)符
d. 拼數(shù)
e. 拼復(fù)合單詞: 例如: >=、 <=、 :=
3) 檢查如下錯(cuò)誤:
a. 程序語(yǔ)言的字符集以外的非法字符
b. 單詞拼錯(cuò),如9A88,而對(duì)于將begin拼寫(xiě)成begon的錯(cuò)誤,只須把begon當(dāng)成標(biāo)識(shí)符即可
對(duì)于給定的一組進(jìn)程,采用優(yōu)先級(jí)加時(shí)間片輪轉(zhuǎn)法進(jìn)行調(diào)度。設(shè)有一個(gè)就緒隊(duì)列,就緒進(jìn)程按優(yōu)先數(shù)(優(yōu)先數(shù)范圍0-100)由小到大排列(優(yōu)先數(shù)越小,級(jí)別越高)。當(dāng)某一進(jìn)程運(yùn)行完一個(gè)時(shí)間片后,其優(yōu)先級(jí)應(yīng)下調(diào)(如優(yōu)先數(shù)加3),試對(duì)如下給定的一組進(jìn)程給出其調(diào)度順序。每當(dāng)結(jié)束一進(jìn)程時(shí)要給出當(dāng)前系統(tǒng)的狀態(tài)(即顯示就緒隊(duì)列)。這里,進(jìn)程可用進(jìn)程控制塊(PCB)表示為如右表所示。
進(jìn)程名 A B C D E F G H J K L M
到達(dá)時(shí)間 0 1 2 3 6 8 12 12 12 18 25 25
服務(wù)時(shí)間 6 4 10 5 1 2 5 10 4 3 15 8