ITfeng

 

2012年4月23日

排序---选择排序

摘要: 选择排序的思路是:先假定一个数十最小的,后面的数与之比较,如果比它小,那么记录下标,替换最小值;依次往复,则排序完毕选择排序的时间复杂度是o(n^2)#include<stdio.h>#include<stdlib.h>#define N 100int buffer[N];void init_array(int a[],int n);void print_array(int a[],int n);void select_array(int a[],int n);int main(){init_array(buffer,N);printf("before sor 阅读全文

posted @ 2012-04-23 16:21 ITfeng 阅读(212) 评论(0) 推荐(0) 编辑

排序---冒泡

摘要: 冒泡排序的思路是将最大的数或者最小的数移到最右端或者最左端第一层for循环的意思是一共比较多少趟,第二层for循环的意思是每次需要比较多少次冒泡排序的时间复杂度是o(n^2)#include<stdio.h>#include<stdlib.h>#define N 100int table[N];void init_array(int array[],int n);void print_array(int array[],int n);void bubble_sort(int array[],int n);int main(){init_array(table,N);pr 阅读全文

posted @ 2012-04-23 16:00 ITfeng 阅读(140) 评论(0) 推荐(0) 编辑

双向链表

摘要: #include<stdio.h>#include<stdlib.h>typedef struct list{int data;struct list*left;struct list*right;}List;void insert_list_2nd(List*head,int data);void insert_list_last(List*head,int data);void insert_list_order(List*head,int data);void print_list(List*head);void delete_list(List*head,int 阅读全文

posted @ 2012-04-23 14:54 ITfeng 阅读(154) 评论(0) 推荐(0) 编辑

不带头结点的链表操作----插入删除打印

摘要: #include<stdio.h>#include<stdlib.h>typedef struct list{int data;struct list*next;}List;List*insert_list_2nd(List*head,int data);List*insert_list_last(List*head,int data);List*insert_list_order(List*head,int data);void print_list(List*head);List*delete_list(List*head,int value);int main() 阅读全文

posted @ 2012-04-23 14:10 ITfeng 阅读(457) 评论(0) 推荐(0) 编辑

导航