Re: [問題] 有誰會C程式語言 (急) 謝謝!!
半夜睡不著所以佛心一下 明天還要上班 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
04/14 02:11, 1F
推
04/14 08:50, , 2F
04/14 08:50, 2F
推
04/14 08:50, , 3F
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
04/14 09:58, 7F
→
04/14 09:58, , 8F
04/14 09:58, 8F
推
04/14 15:41, , 9F
04/14 15:41, 9F
推
04/15 01:26, , 10F
04/15 01:26, 10F
推
04/15 02:49, , 11F
04/15 02:49, 11F
→
04/15 02:50, , 12F
04/15 02:50, 12F
推
04/15 16:12, , 13F
04/15 16:12, 13F
→
04/15 19:39, , 14F
04/15 19:39, 14F
→
04/15 19:40, , 15F
04/15 19:40, 15F
→
04/15 19:41, , 16F
04/15 19:41, 16F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):