原檔連結 1. 行號產生程式---輸入任一英文文字檔案, 輸出經加行號後原始文字檔案及其之程式並另存新檔 範例如 ---Input file==>xxx.txt 其內容為: The web is changing every day. It is not only a place for nifty web pages, but also a communication medium where business can perform daily routines. ---執行如abc < xxx.txt ---輸出如下 0001 The web is changing every day. 0002 It is not only a place for nifty web pages, 0003 but also a communication medium 0004 where business can perform daily routines. 基本上,這題只要找到'\n'然後行數+1,比較困難的是要找到檔案輸入的語法。 2. 檔案內容檢視程式---輸入任一檔案(含文字檔或執行檔或圖檔等各種檔案), 輸出其16進位碼及ASCII對照碼 範例如: ---Input file==>winclose.gif, ---執行如abc < winclose.gif ---輸出如下: ------dump file: winclose.gif------ 0000000 47 49 46 38 39 61 10 00 - 0e 00 a2 00 00 ff ff ff 0000010 47 3f 47 d7 cf cf 87 7f - 87 07 07 07 00 00 00 00 0000020 00 00 00 00 00 2c 00 00 - 00 00 10 00 0e 00 00 03 0000030 33 08 ba dc 01 22 ca 29 - c7 a3 38 5a 18 09 99 9e 0000040 76 49 a1 50 0a 1b e5 9d - e8 08 7e 53 fa b2 72 07 0000050 9f 35 5b d6 59 e5 f6 22 - c0 60 48 2c 16 03 c8 a4 0000060 72 89 4c 00 00 3b ------102 bytes------ 這題跟上一題差不多,只是要找出輸入檔案和抓出程式碼的語法… 3. 月曆程式---輸入西元年月, 輸出其月曆, 注意閏月29及大小月的問題 範例如 ---Input arguments(年 月 星期): 2007 6 5 ---執行如abc 2007 6 5 ---輸出如下 June 2007 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 這題第一步是算出是否為閏年、閏月,還有該月的總日數。較難的是找出該月第一天是星期幾。 4. 排列程式---將參數排列 ---執行如abc sun mon tue wed thu fri sat ---輸出如下 fri mon sat sun thu tue wed 這題課本上有類似,可以用比大小或二分樹來做。 5. 階乘程式---輸入1~100, 輸出其無誤差之答案 這個…以前做過吧? 6. 列印1至10000的所有快樂數---Find all Happy Numbers between 1 to 10000. Definition: a positive numer s, let s' be the square sum of all digits of s. If there exists a subsequent square sum of s which is 1, then s is a happy number, otherwise s is an unhappy number. for example, 7 is happy number because 7 -> 49 -> 97 ->130 -> 10 -> 1. 那個…快樂數是啥? 7. 列印所有單字---輸入任一英文文字檔案, 輸出所有英文單字不含標點符號 ---Input file==>xxx.txt 其內容為: The web is changing every day. It is not only a place for nifty web pages, ... ---執行如abc < xxx.txt ---輸出如下 0001 The 0002 web 0003 is 0004 changing 0005 every 0006 day 0007 It 0008 is 0009 not 0010 only 0011 a 0012 place 0013 for 0014 nifty 0015 web 0016 pages ... 拿getnextword來改吧,原理差不多。 8. 列印1~100的所有質數 ---輸出 2 3 5 7 11 13 ... 97 找出質數的算法公式。 9. 算出所有參數的最大公因數GCD ---執行如abc 12 96 320 ---輸出 5 以前寫過=_= 10. 算出所有參數的最小公倍數LCM ---執行如abc 12 96 320 ---輸出 800 這個…要找公式。
創作者介紹
創作者 隱狼原 的頭像
otn147

隱狼原

otn147 發表在 痞客邦 留言(0) 人氣( 217 )