Re: [問題] 有誰會C程式語言 (急) 謝謝!!

看板Programming作者 (Bird)時間17年前 (2008/04/14 01:27), 編輯推噓9(907)
留言16則, 10人參與, 最新討論串2/2 (看更多)
半夜睡不著所以佛心一下 明天還要上班 Orz ※ 引述《Vxprincessx (^^)》之銘言: : 1. [清除記憶體]Write a function "void bzero(char*p, int n)" to set the n : contiguous bytes of memory starting from the pointer p to '\0'. #include <cstring> void bzero(char*p, int n) { memset(p, 0, n); } : 2. [設定記憶體]Write a function "void bset(char*p, int n, char x)" to set : n contiguous bytes of memory starting from the pointer p to the value of x. #include <cstring> void bset(char*p, int n, char x) { memset(p, x, n); } : 3. [反向字元搜尋]Write a function "int findlast(char *s, char c)" to : retur : the index position of the last occurrence of a specified char c within the : string s, and return -1 if not found, such as findlast("language",'a') : returns 5. #include <string> int findlast(char *s, char c) { std::string str(s); return str.rfind(c); } : 4. [八進位字串轉整數]Write a function "int otoi(char h[])" to convert an : octal string h to an integer, such as otoi("377") returns 255. #include <stdio.h> int otoi(char h[]) { int i; sscanf(h, "%o", &i); return i; } : 5. [十六進位字串轉整數]Write a function "int xtoi(char h[])" to convert a : hexadecimal string h to an integer, such as xtoi("3ff") returns 1023. #include <stdio.h> int xtoi(char h[]) { int i; sscanf(h, "%x", &i); return i; } : 6. [去兩邊空白]Write a function "void trim(char s[])" to remove the : rightm : and leftmost spaces of string s, such as trim(" ab c ") gets "ab c". #include <boost/algorithm/string.hpp void trim(char s[]) { boost::algorithm::trim(s); } : 希望有好心人幫幫我這可憐的學生   : 這科沒過就要延畢了 : 拜託各位大大幫幫忙 : 我會感激不盡  謝謝 不客氣 你們老師應該會覺得你很厲害 都只要一行就寫完了 半夜寫程式要開燈 不然對視力不好喔 要是因為都用現成的函式被當掉別怪我喔 重修一遍對你可能比較好喔 科科 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.193.35.97 ※ 編輯: yzugsr 來自: 123.193.35.97 (04/14 01:27)

04/14 02:11, , 1F
老師:終於有同學達到我的要求了... T__T
04/14 02:11, 1F

04/14 08:50, , 2F
代替我朋友謝謝你 XD
04/14 08:50, 2F

04/14 08:50, , 3F
老師應該不知道什麼是boost
04/14 08:50, 3F

04/14 09:56, , 4F
其實我覺得延畢好..很多畢業出來的程式能力
04/14 09:56, 4F

04/14 09:57, , 5F
很驚人....@@
04/14 09:57, 5F

04/14 09:58, , 6F
而且我不覺得老師需要這個給初學者寫成一行
04/14 09:58, 6F

04/14 09:58, , 7F
C? C++?
04/14 09:58, 7F

04/14 09:58, , 8F
不過原po很熟c/c++
04/14 09:58, 8F

04/14 15:41, , 9F
無論如何 謝謝你!! 
04/14 15:41, 9F

04/15 01:26, , 10F
拿那些函式去google一下吧,別真的只寫一行
04/15 01:26, 10F

04/15 02:49, , 11F
y大真強~!!!不過想跟原PO說...
04/15 02:49, 11F

04/15 02:50, , 12F
這些只要有專業一點的程式書,應該都查的到喔~
04/15 02:50, 12F

04/15 16:12, , 13F
sscanf 可以這樣用呀... (筆記)
04/15 16:12, 13F

04/15 19:39, , 14F
boost有的c版本沒有吧?
04/15 19:39, 14F

04/15 19:40, , 15F
我指上面的string.hpp,學校應會要求用
04/15 19:40, 15F

04/15 19:41, , 16F
標準C語法來做,所有C版本都有的function
04/15 19:41, 16F
文章代碼(AID): #180a9c10 (Programming)
文章代碼(AID): #180a9c10 (Programming)