C编程
放狼的爷们
阳光 儒雅 博学 勤思 死宅
展开
-
Keyboard Row
#include #include //字符串1是否包含字符串2,在同一行 int inStr(char *str1, char *str2) { int i, j, str1len = strlen(str1), str2len = strlen(str2); int flag = str2len; int temp; for (i = 0; i <原创 2017-07-02 22:09:41 · 172 阅读 · 0 评论 -
hamming distance
#include int hammingDistance(int x, int y) { int z = x^y, count = 0; while (z) { count ++; z = z & (z - 1); } return count; } void main() { unsig原创 2017-06-26 23:46:34 · 186 阅读 · 0 评论 -
Reshape the Matrix
/** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *columnSizes array. * Note: Both returned array and *columnSizes array must be malloced, assume caller原创 2017-07-05 23:54:06 · 287 阅读 · 0 评论 -
Reshape the Matrix
/** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *columnSizes array. * Note: Both returned array and *columnSizes array must be malloced, assume caller原创 2017-07-05 23:54:09 · 243 阅读 · 0 评论 -
Array Partition I
#include #include void swap(int *a, int *b) { int temp; temp = *a; *a = *b; *b = temp; } int arrayPairSum(int* nums, int numsSize) { int i, j, temp; for (i = 0; i < numsSize; i++) { for (j原创 2017-06-27 20:40:40 · 72 阅读 · 0 评论 -
Number Complement
int findComplement(int num) { /*int count = 0; if (num == 1) return 0; while (num) { num &= (num - 1); count++; } return count;*/ int i,flag = 0; for (i = 31; i >= 0; i--) { if ((num &原创 2017-06-27 23:59:34 · 183 阅读 · 0 评论