- 博客(20)
- 资源 (5)
- 收藏
- 关注
原创 哈夫曼树的构造
哈夫曼树的特点:n个结点全为叶子结点,并且总共有2*n-1个结点,权值路径之和最小。#include #include #define max 100struct huffmantree{ int weight; struct huffmantree *lchild; struct huffmantree *rchild; struc
2013-08-28 00:15:37 1088
原创 比较两个数的大小,交换两个数的 方法总结
面试宝典中看到的,记录下来,与大家共勉1、比较两个数的大小/*比较两个数的大小,不要使用if判断*/#include #include int main(){ int a, b; printf("please input a and b:\n"); scanf("%d%d",&a,&b); //方法1 int max
2013-08-27 19:14:08 5362
原创 图的深度优先搜索(DFS)、广度优先搜索(BFS)
深度优先搜索(DFS)、广度优先搜索(BFS)图的邻接矩阵形式#include #include #include #define MAX 100typedef struct{ int edges[MAX][MAX]; //邻接矩阵 int n; //顶点数 int e;
2013-08-24 16:07:45 910
原创 二叉树前序序列、中序序列、后序序列互求
两种情况:1、已知前序序列和中序序列,求后序序列2、已知后序序列和中序序列,求前序序列//已知前序序列和中序序列,求后序序列#include void preorder_inorder_to_postorder(char *preorder, char *inorder, int length){ if(length > 0) {
2013-08-23 21:47:07 1859
转载 中国大陆开源镜像站汇总
1.企业贡献: 搜狐开源镜像站:http://mirrors.sohu.com/ 网易开源镜像站:http://mirrors.163.com/ 2.大学教学: 北京理工大学: http://mirror.bit.edu.cn (IPv4 only) http://mirror.bit6.edu.cn (IPv6 only) 北
2013-08-23 10:40:38 1217
转载 C语言经典著作导读
本人不是卖书的,我也不会给出任何购书链接,只是给C语言学习者推荐一条学习的方向。如果你喜欢看电子书网上很多,如果你喜欢纸质那么就买吧,经典的书值得收藏,是对版权的尊重! 基础篇1.《写给大家看的C语言书(第2版)》原书名: Absolute Beginner's Guide to C (2nd Edition) 原出版社: Sams 作者: (美)G
2013-08-23 10:32:52 962
原创 二叉排序树的操作(建立、插入、删除和查找)
二叉排序树的建立、插入、删除和查找(删除待补充)#include #include typedef struct node{ int key; struct node *lchild,*rchild;}BSTNode;BSTNode *InsertBST(BSTNode *T, int key){ BSTNode *f, *p = T;
2013-08-22 15:55:41 5860 1
原创 C/C++排序之五(堆排序)
堆排序heap_sort#include void adjust_heap(int *begin, int *end, int index){ int temp = *(begin + index); int child = (index << 1) + 1; while(child <= end - begin) {
2013-08-21 21:50:33 628
原创 C/C++ 排序之四(计数排序)
计数排序counting sort#includevoid counting_sort( int a[], int n ){ int count = 0 ; int k = 0 ; while( k < n - 1) { for( int i = k + 1 ; i < n ; i++ ) {
2013-08-20 21:03:30 763
原创 C/C++ 排序之三(快速排序(递归))
快速排序(递归)#include int *parse(int *begin, int *end){ int temp = *begin;//存储第一个数 //寻找第一个数要分割的位置 while(begin < end) { while(begin < end && temp <= *end) end --;
2013-08-20 19:38:46 792
原创 C/C++查找之一(顺序查找、折半查找(二分查找))
进行查找算法,首先得明确数据的存储结构:顺序存储(数组)或链式存储(链表)对于顺序存储,可以有:顺序查找和折半查找(对于后者的前提是此顺序表是有序的);对于链式存储,只能进行顺序查找。1、顺序查找//顺序表的查找#include void search(int *data, int n, int t){ int i, num=0; for(i = 0
2013-08-20 14:32:15 4240
原创 C/C++排序之二(直接插入排序、 折半插入排序、归并排序(递归))
直接插入排序、 折半插入排序4、直接插入排序insertion_sort#include void insertion_sort(int *begin, int *end){ int *i, *j, temp; for(i = begin + 1; i <= end; i ++) { temp = *i; for
2013-08-19 21:17:11 1392
原创 C/C++ 排序之一(冒泡排序、选择排序、交换排序)
#include void bubble_sort(int *begin, int *end){ int *i, *j, *k; for(i = end; i >= begin; i --) for(j = begin; j + 1 <= end; j ++) if(*j > *(j + 1))
2013-08-19 19:33:58 1105
原创 C 语言中的字符函数和字符串函数
ANSI C标准要求在使用字符函数时要包含头文件“ctype.h”,在使用字符串函数时要包含头文件“string.h”函数名函数原型功能返回 值包含文件isalnum 检查ch是否是英文字母或数字
2013-08-18 14:01:02 1131
原创 C及C++运算符的优先级和结合性
C语言运算符的优先级和结合性,自上而下优先级逐次下降:PrecedenceOperatorDescriptionAssociativity1++ --Suffix/postfix increment and decrementLeft-to-right()Function call
2013-08-18 13:03:26 922
转载 TIOBE Programming Community Index for August 2013
摘自:http://www.tiobe.com/index.php/content/paperinfo/tpci/index.htmlTIOBE Programming Community Index for August 2013August Headline: Search engine changes affect C and Objective-C most
2013-08-17 17:11:31 1057
原创 链表基本操作(建立、修改,插入、删除、打印)
#include #include struct list{ int data; struct list *next;};//头插法建立链表struct list *headcreate(){ struct list *head, *p; int N,i; head=NULL; printf("输入要建立的链表结点个数N=");
2013-08-17 16:19:46 737
转载 怎样SSH远程连接虚拟机中的Ubuntu
1、虚拟机中设置网络连接模式为桥接模式,Ubuntu 中手动设置网络参数,将Ubuntu的IP设置成与windows同一网段,并且确保能互相ping通。2、安装SSH-server终端下输入命令: sudo apt-get install openssh-server3、启动SSH-serversudo /etc/init.d/ssh start4、wind
2013-08-10 10:11:42 973
转载 linux下的基本网络配置
摘自:http://www.2cto.com/os/201109/104152.html第一种:使用命令修改(直接即时生效,重启失效)#ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up说明:eth0是第一个网卡,其他依次为eth1,eth*192.168.0.1是给网卡配置的第一个网卡配置的ip地址netmask
2013-08-10 09:31:32 631 1
转载 Linux如何设置快速的debian源
使用apt-spy,可以自动测试到哪个源的下载速度最快,并自动将最快的源写入配置文件 由于刚装好系统是没有apt-spy,所以先找个源先安装apt-spy 设置临时源 vi /etc/apt/sources.list #添加以下一行到文件最后 http://deb http://http.us.debian.org/debian stable main更新软件包列表并安
2013-08-08 20:40:29 656
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人