09 2011 档案
My first Qt program
摘要://我的第一个Qt程序 留个纪念吧!#include <QtGui/QApplication>#include "qmlapplicationviewer.h"#include <QLabel>#include <QPushButton>int main(int argc, char *argv[]){ QApplication app(argc, argv); QLabel *label = new QLabel("<h2><i>Hello </i>" "<font 阅读全文
posted @ 2011-09-27 13:56 Jiang, X. 阅读(180) 评论(0) 推荐(0) 编辑
最大公约数的欧几里德[辗转相除]算法及其扩展
摘要:欧几里德算法描述: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. 阅读(314) 评论(0) 推荐(0) 编辑
Volatile关键字
摘要: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. 阅读(150) 评论(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. 阅读(227) 评论(0) 推荐(0) 编辑
sizeof()与strlen()的区别与联系
摘要:从外部特性来看:#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. 阅读(381) 评论(0) 推荐(0) 编辑
Some Const Objects Are Defined in Headers
摘要:Some Const Objects Are Defined in Headers首先明确一点:const型变量的作用域为其定义的文件,在其它文件中无法调用。example:// file1:const int var1 = 10;int var2 = 20;// file2:#include <stdio.h>extern int var1;extern int var2; int main(){ printf("%d", var1); printf("%d", var2); getchar(); return 0;} //error LN 阅读全文
posted @ 2011-09-10 18:13 Jiang, X. 阅读(252) 评论(0) 推荐(0) 编辑
内存对齐
摘要:内存对齐 变量的存储不是简单的堆砌,而是要按照一定的规则对齐。Example:// 内存对齐.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <iostream>//#pragma pack(1) //用来设定变量以n字节方式对齐using namespace std;struct st_1{ char a; int b; short c;}; struct st_2{ short c; ... 阅读全文
posted @ 2011-09-08 19:36 Jiang, X. 阅读(195) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示