原创 atoi函數和itoa函數C代碼實現

一、atoi函數實現      1、atoi (表示 ascii to integer)是把字符串轉換成整型數的一個函數。      2、C代碼實現如下   #include <stdio.h> #include <ctype.h>

原创 統計程序輸入中各個數字、空白符和其他字符出現的次數

1、if-else語句C實現 #include <stdio.h> /* count digits, white space, others */ main() { int c, nwhite, nother; int

原创 strlen函數C實現

1、函數功能介紹       strlen 函數用來求字符串的長度(包含多少個字符,不包含'\0')。   2、函數實現C代碼 #include <stdio.h> int strlen1(char s[]) { int

原创 二分查找法(Binary Search)

一、算法簡介 分查找也稱折半查找(Binary Search),它是一種效率較高的查找方法。首先,假設表中元素是按升序排列,將表中間位置記錄的關鍵字與查找關鍵字比較,如果兩者相等,則查找成功;否則利用中間位置記錄將表分成前、後兩個子表,如

原创 Linux啓動過程

     英文版URL:http://www.ibm.com/developerworks/linux/library/l-linuxboot/?ca=dgr-lnxw09LinuxBoot         Linux系統的啓動過程是

原创 把由十六進制數字組成的字符串轉換爲與之等價的整數值

#include "stdafx.h" #include <string.h> /*htoi: converts hexadecimal string to integer */ int htoi(char s[]) { int he

原创 隊列的鏈表實現

//隊列的鏈表實現 #include "stdafx.h" #include <malloc.h> #define TRUE 1 #define FALSE 0 #define OK 1 #define ERR 0 typ

原创 Volatile相關的一些底層知識

CPU是你機器的心臟,最終由它來執行所有運算和程序。主內存(RAM)是你的數據(包括代碼行)存放的地方。CPU和主內存之間有好幾層緩存,因爲即使直接訪問主內存也是非常慢的。如果你正在多次對一塊數據做相同的運算,那麼在執行運算的時候把它加載

原创 棧的數組和鏈表實現

一、順序棧的數組實現 #include "stdafx.h" #include <malloc.h> #define MAX_SIZE_STACK 1024 /*棧的大小*/ #define IS_EMPTY_STACK

原创 判斷一個數是否爲素數

</pre><pre name="code" class="cpp">/*判斷素數的方法:用一個數分別去除2到sqrt(這個數),如果能被整除,則表明此數不是素數,反之是素數。*/   #include "stdafx.h" #inclu

原创 字節大小端判斷

/* * ===================================================================================== * * bytes_order.c * * D

原创 直接插入排序

#include "stdafx.h"#include <string.h> void insertion_sort(int array[],unsigned int len) { unsigned int i,j; int tem

原创 求兩個整數的最大公約數和最小公倍數

//輸入兩個正整數m和n,求其最大公約數和最小公倍數。 //程序分析:利用輾除法 #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { int a = 0,b=0,num

原创 單鏈表的實現

<pre name="code" class="cpp">//單鏈表的實現+鏈表的bubble 排序 #include "stdafx.h" #include<malloc.h> typedef int status; typedef

原创 矩陣相乘

// MatrixMutiply.cpp : 定義控制檯應用程序的入口點。 //矩陣相乘 #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { int a[5][4],