![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
学习笔记
学习ing的小东东
这个作者很懒,什么都没留下…
展开
-
数据结构——栈
/*1.用数组栈实现括号匹配 input: ()()[][]{}{} output:yes input([]) output:yes input:([)] output:no 从main开始,刚开始没思路就从输入开始。 */ #include #include #include #define MAXSIZE 100 typedef stru原创 2016-11-28 22:30:06 · 213 阅读 · 0 评论 -
数据结构——list
实现单链表的数据插入和删除。#include <stdio.h> #include <stdlib.h>typedef struct list{ int data; struct list* next; }List;void print_list(List* head) { while(head)//这里直接用head,因为这里只需要遍历链表 { pr原创 2016-12-03 14:05:27 · 318 阅读 · 0 评论 -
数据结构——快速排序
题目要求实现1000000内的数的快速排序。这里的方法用了多个数组,还有一种只用一个数组的方法。#include <stdio.h> #include <stdlib.h> #define N 1000000int a[N]; int a1[N]; int a2[N];void random_array(int a[],int n) { int i; for(i=0;i<n;i++)原创 2016-12-04 17:00:55 · 228 阅读 · 0 评论 -
数据结构——二分法查找
用二分法查找首先要将产生的一组随机数排序,然后调用二分查找函数。找到则输出这个数,找不到则输出错误信息。#include <stdio.h> #include <stdlib.h> #define N 100 #define ERROR -1void random_array(int a[],int n) { int i=0; for(i=0;i<n;i++)原创 2016-12-05 18:31:58 · 1098 阅读 · 0 评论 -
数据结构——堆排序和归并排序
这2种排序是几天前学的,现在把他们写在一起。 堆排序的思路: 1.a[0]是不参与排序的,可以先把a[0]设成-1 2.对数组进行一次整体的调整(可以从n/2往前调整,也可以从n往前调整,因为不满足j<=high时不调整) 3.调整函数里,让a[2*i]和a[2*i+1]比较,较大的数与a[i]交换 4.由于最大的数已经被调整到了a[1],所以将a[1]与数组最后一个数交换,同时最后一个数原创 2016-12-09 18:13:48 · 308 阅读 · 0 评论