
c/c++
xingfudage1986
这个作者很懒,什么都没留下…
展开
-
C++里的计数器class
#include #include #include #include class AutoTimer{ public: AutoTimer(const char *msg){ _msg = msg; gettimeofday(&begin, NULL)原创 2011-09-29 19:32:59 · 909 阅读 · 0 评论 -
求二进制数中1的个数
解法一:除2看余数int Count(BYTE v){ int num = 0; while(v) { if(v % 2 == 1) { num++;转载 2011-09-30 19:01:24 · 645 阅读 · 0 评论 -
字符串处理的一些题
1 写一个函数removesubstr(char *s, char *t),功能是从字符串s中找子串t,并将t从s中删除。代码:int removesubstr(char *s, char *t){ char *dst, *sp, *tp; int find = 0原创 2011-10-13 18:29:52 · 574 阅读 · 0 评论 -
字符串翻转的问题
输入一个英文句子,要求翻转句子中单词的顺序,但单词内字符顺序不变,句子中单词以空格符隔开例如输入“welcome to china”,则输出“china to welcome”代码如下:#define reverse(p1, p2) while(p1<=p2) { / char ch; / ch=*p1;原创 2011-10-14 13:15:18 · 545 阅读 · 0 评论