2014年7月24日
摘要: 题目:输入一个整数,输出该数二进制表示中1的个数。// 二进制中1的个数#include int wrong_count_1_bits(int n) // 错误解法: 当n为负数时, n>>=1右移, 最高位补1, 陷入死循环{ int count = 0; while(n) { ... 阅读全文
posted @ 2014-07-24 19:45 DayByDay 阅读(305) 评论(0) 推荐(0) 编辑
摘要: // 判断两个单词是否互为变位词: 如果两个单词中的字母相同,并且每个字母出现的次数也相同, 那么这两个单词互为变位词#include #include int is_anagram(char *s1, char *s2) // 判断两个数是否互为变位词, 若是返回1{ if(strlen(s... 阅读全文
posted @ 2014-07-24 01:39 DayByDay 阅读(292) 评论(0) 推荐(0) 编辑
摘要: // 从第一个字符串中删除第二个字符串中出现过的所有字符#include char* remove_second_from_first( char *first, char *second ){ if( first == NULL || second == NULL ) { ... 阅读全文
posted @ 2014-07-24 01:18 DayByDay 阅读(686) 评论(0) 推荐(0) 编辑
摘要: 题目:在字符串中找出第一个只出现一次的字符。如输入"abaccdeff",这输出'b'// 第一个只出现一次的字符#include char first_not_repeat_char(char *s){ int count[256]={0}; char *pkey; if( s=... 阅读全文
posted @ 2014-07-24 01:01 DayByDay 阅读(218) 评论(0) 推荐(0) 编辑
摘要: /* * 动态分配存储的顺序表 */#include #include #define INIT_SIZE 100#define EXPAND_SIZE 50typedef int ElemType;typedef struct { ElemType *head; int len; //... 阅读全文
posted @ 2014-07-24 00:31 DayByDay 阅读(1228) 评论(0) 推荐(0) 编辑