Time of Update: 2018-12-03
掌握好常用的排序演算法,在實際的項目開發中可以節省很多的時間。每一種排序演算法在執行的效率上是存在差別的,這些微小的時間差,也許在平常的聯絡當中感覺不到,但是涉及到資料量比較大或者是在資源比較緊張的系統中就顯得尤其的重要,比如嵌入式系統。下面簡要介紹三種常用的排序演算法以及他們的執行效率的比較。 冒泡排序: 思路:將相鄰的兩個數比較,將較小的數調到前頭;有n個數就要進行n-1趟比較,第一次比較中要進行n-1次兩兩比較,在第j趟比較中,要進行n-j次兩兩比較。
Time of Update: 2018-12-03
from : http://blog.chinaunix.net/uid-21556133-id-118208.html安裝Sqlite3:從www.sqlite.org上下載Sqlite3.2.2運原始碼,依照Readme中的步驟:tar xzf sqlite3.2.2.tar.gzmkdir bldcd bld../sqlite3.2.2/configuremakemake install然後在shell下運行 sqlite3 test.db命令可以檢驗是否已經安裝成功。0.
Time of Update: 2018-12-03
#include<stdio.h>struct stu{char name[10];intnum;int age;char addr[15];}boya[2],boyb[2],*pp,*qq;#define FILEPATH "D:\\test.txt"void main(){FILE *fp;char ch;int i;pp = boya;qq = boyb;if((fp = fopen(FILEPATH,"wb+")) == NULL){printf("Cannot open
Time of Update: 2018-12-03
以下代碼來自小甲魚<零基礎學習C語言>#include<stdio.h>#include<stdlib.h>void main(){FILE *f_pic, *f_file, *f_finish;char ch;char pic_name[20],file_name[20],finish_name[20];printf("請輸入需要合成的圖片和檔案的名稱:\n");printf("圖片: ");scanf("%s",pic_name);printf("檔案:
Time of Update: 2018-12-03
#include<stdio.h>#define FILEDIR "D:\\test1.txt"int main(){FILE *fp;char ch='a';if ( (fp =fopen(FILEDIR,"at+")) == NULL ){printf("Cannot open file strke any key exit!");getch();exit(1);}printf("input a string:\n");ch = getch();while(ch != '\r')
Time of Update: 2018-12-03
/* * sum9-2 - sumary how many digit from 1 to 100 * * Author: li ming<xxxxx@163.com> * Creat Data: 2013-4-30 * Revision 1.1 * + debug printf */#include<stdio.h>/* * count - conut how many digit in num * @num: the
Time of Update: 2018-12-03
以下代碼來自播布客視頻,亞嵌李明老師課程.#include<stdio.h>#if 0void swap(int a, int b){ char tmp; tmp = b; b = a; a = tmp;}#endif#define SWAP(a, b) \do{ \ char tmp; \ \ tmp = b;
Time of Update: 2018-12-03
#include<stdio.h>void main(int argc,char *argv[]){FILE *fpRead, *fpWrite;char ch;if(argc == 1){printf("have not enter file name strike any key exit");getch();exit(0);}if((fpRead = fopen(argv[1],"rt")) == NULL){printf("Cannot open %s\n",argv[1])
Time of Update: 2018-12-03
在c語言中經常會使用static(靜態)和extern(外部的)關鍵字,但是如果使用不當可能會對程式的設計帶來麻煩,這裡作些介紹。一、聲明或定義變數 1、局部變數: 用static在函數內部定義的變數是靜態局部變數,儲存在記憶體的靜態/全域區,其生命週期是整個來源程式。但是範圍與自動變數相同,只能在該函數中使用,退出函數後,此變數繼續存在,但不可使用。若不給靜態局部變數賦值,則系統自動賦值0(自動變數初值隨即)。 2、全域變數
Time of Update: 2018-12-03
#include<stdio.h>struct stu{char name[10];intnum;int age;char addr[15];}boya[2],boyb[2],*pp,*qq;#define FILEPATH "D:\\test.txt"void main(){FILE *fp;char ch;int i;pp = boya;qq = boyb;if((fp = fopen(FILEPATH,"wb+")) == NULL){printf("Cannot open
Time of Update: 2018-12-03
1. 關於素數的演算法:用兩個for迴圈,外迴圈是要求的範圍,內迴圈是從2到sqrt(外迴圈範圍中的一個值+1);設定一個flag,來表明是否是素數;具體實現:#include <stdio.h>#include <math.h>int main (void){int i, j;bool flag = 0; //設立標誌位,0表示非素數,1表示素數;for(i = 101 ; i <= 200 ; i++) //求1
Time of Update: 2018-12-03
1. 指標數組和數組指標int *array[10]說明:聲明了array是一個擁有10個元素的數組,其中每個元素都是一個指標,該指標指向整型;(一個數組,存放著10個指標)int (*array)[10]說明:聲明了*array是一個擁有10個元素的數組,其中每個元素都是整型,array就是指向這樣的數組的指標。(一個指標,指向有10個整型元素的數組)2. *p++與(*p)++的區別*p++的含義是與*(p++)相同,主要是在C語言中*與++的優先順序同處在優先順序的第二層級上,而且優先順序
Time of Update: 2018-12-03
#include <stdio.h>#include <stdarg.h> 1. 在c檔案中添加如下原始碼static char msg_buf[16*1024];void dump_printf(char *file,int line,char *fmt,...){#if 1 //time_t tt; //struct tm *now; va_list ap; unsigned int fmt_offset = 0; //time(&tt); //now =
Time of Update: 2018-12-03
最近再看網路方面的程式設計,由於tcp協議是基於位元組流的形式,某時突然想到如何進行變數的十六進位輸出。故此小結了一下這篇文章。例子是用C語言給出的。先說一下我的編程環境,我是在windows作業系統下用vs2005進行編譯,cpu是intel的P4,因此那些變數的位元組數分別是: char 是 1 位元組 short 是 2 位元組int, long, float ,指標 是 4 位元組
Time of Update: 2018-12-03
所有操作都是在Linux VIM下進行的:command: normal gg=G或set foldmethod=indent如果你想重徘某一個地區內的代碼,這兒還有一個方法: " = { 或 } " . 注: 先按'='鍵 再按 '{'(按住shift)是往上的某個區, '}'是往下的某個地區. 再注: "地區"的意思是緊跟的兩個空白行之間的地區. 如果你的游標在'{'或'}'字元上時,它重排的地區是對應的'}或"{"之間的地方..如果還明白,那麼去Vim 上試吧
Time of Update: 2018-12-03
在開發Android應用的過程中,通常有兩種方式:NDK和eclipse,或者直接在Android SDK增加。這裡介紹如何在Android SDK環境中增加一個應用程式。其中涉及到JNI,JAVA對JNI的調用,其中JNI代碼檔案為C++。 第一步,建立JNI層代碼,注意,JNI代碼的路徑與JAVA的代碼路徑有很大的關係,一定要保持一致。 在frameworks/base/core/jni目錄下建立JNI C++檔案android_test.cpp,內容如下: #define
Time of Update: 2018-12-03
//=====================================================================//TITLE:// 為什麼Windows Phone 7不支援C++?//AUTHOR:// norains//DATE:// Thursday 5-August-2011//Environment:// Windows Phone 7//=============================================
Time of Update: 2018-12-03
時光回溯,一個月前。 同事小愚辭職,理由是C語言太麻煩,指標指來指去,還有什麼記憶體太難控制種種,於是改學JAVA還是C#去了。可是公司項目還要進行啊,走了一個,還要招一個填補啊。可這年頭,招個熟練的C++高手還真不容易啊。不知道為什麼,來面試的都是那些JAVA啊,C#的高手,他們能夠在短短一個小時之內寫完一個C用一天才能完成的功能。可是,這也沒用啊,我們是做嵌入式開發的,唯一的工具就是C/C,哦,不是,還有一個,彙編。所以,眾多來面試的高手,我們只能無奈和他們說拜拜。 之後過了接近3
Time of Update: 2018-12-03
函數定義如下:section("L1_code") int InitProcessorSpecificConfiguration(ADI_NET2272_DEVICE *pDev){unsigned short usValue;volatile unsigned int v;#if defined(__ADSPBF533__)/* configure interrupt flag as level sensitive input from NET2272 */usValue =
Time of Update: 2018-12-03
/*************************************************************************** * Physical Endpoint structure. USB core operates at logical endpoint level. * once host selects a configuration and an interface the associated logical endpoint objects *