- 博客(6)
- 收藏
- 关注
原创 1002. A+B for Polynomials (25)
This time, you are supposed to find A+B where A and B are two polynomials.InputEach input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial
2016-12-14 08:59:19
215
原创 数据结构——堆排序和归并排序
这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
336
原创 数据结构——二分法查找
用二分法查找首先要将产生的一组随机数排序,然后调用二分查找函数。找到则输出这个数,找不到则输出错误信息。#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
1136
原创 数据结构——快速排序
题目要求实现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
274
原创 数据结构——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
349
原创 数据结构——栈
/*1.用数组栈实现括号匹配input: ()()[][]{}{} output:yesinput([]) output:yesinput:([)] output:no从main开始,刚开始没思路就从输入开始。*/#include #include #include #define MAXSIZE 100typedef stru
2016-11-28 22:30:06
238
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人