2011年9月18日
摘要: 欧几里德算法描述:E1.[求余数] 以n除m并令r为所得余数。(我们将有0 ≤ r ≤ n。)E2[余数为0?] 若r=0,算法结束,n即为答案。E3[减少] 置m←n, n←r,并返回步骤E1.其原理依赖于下面的定理:gcd(a, b) = gcd(b, a mod b)证明:a可以表示成a = kb + r,则r = a mod b假设d是a, b的一个公约数,则有d | a, d | b,而r = a - kb,因此d | r因此d是(b, a mod b)的公约数假设d 是(b,a mod b)的公约数,则d | b , d |r ,但是a = kb +r 因此d也是(a,b)的公约数 阅读全文
posted @ 2011-09-18 16:25 Jiang, X. 阅读(300) 评论(0) 推荐(0) 编辑
摘要: Volatile关键字· The compiler assumes that, at any point in the program, avolatile variable can be accessed by an unknown process that uses or modifies its value. Therefore, regardless of the optimizations specified on the command line, the code for each assignment to or reference of avolatile vari 阅读全文
posted @ 2011-09-18 15:09 Jiang, X. 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 1、要使用可变参数就要包含头文件 #include <stdarg.h>。2、在该头文件中定义了一个va_list类型,在vadefs.h中发现:typedef char * va_list;3、在该头文件中还定义了用来遍历参数列表的4个宏:#define va_start _crt_va_start#define va_arg _crt_va_arg#define va_end _crt_va_end#define _crt_va_start(ap,v) ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) )#define _crt_va_ 阅读全文
posted @ 2011-09-18 14:36 Jiang, X. 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 从外部特性来看:#include <stdio.h>#include <string>int main(){ char array[] = "12345"; int n = sizeof(array); // n is 6 int m = strlen(array); // m is 5 array[3] = 0; n = sizeof(array); // n is 6 m = strlen(array); // ... 阅读全文
posted @ 2011-09-18 13:40 Jiang, X. 阅读(379) 评论(0) 推荐(0) 编辑