随笔分类 - C Language
摘要:1 #include <stdio.h> 2 3 int main() 4 { 5 int a, b; 6 7 a ^= b; 8 b ^= a; 9 a ^= b;10 11 return 0;12 }运用了异或的性质:两个相同的数异或等于0,一个数与0异或等于自身,即:a^a = 0, a^0=a.缺点:只适用于32-bit以内的整型,PS:此性质还可以用来找出1...n,n个数中缺少的一个数. 1 #include <stdio.h> 2 3 int main() 4 { 5 int n; 6 int a[10]; 7 while (scanf("%d&
阅读全文
摘要:[代码]拷贝的结果是:s1 = "",s1[1] = 0;分析:strcpy()函数的功能是字符串拷贝,而字符串是以/0为结束标志。所以简单的把strcpy()当成数组的拷贝是错误的想法。参考:strcpyfunction<cstring>Copy stringCopies the C string pointed by source into the array pointed by...
阅读全文

浙公网安备 33010602011771号