- 博客(22)
- 资源 (1)
- 收藏
- 关注
原创 LeetCode-Algorithms-19.删除链表的倒数第N个节点(C)
1. 题目描述 给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。 示例: 给定一个链表: 1->2->3->4->5, 和 n = 2. 当删除了倒数第二个节点后,链表变为 1->2->3->5. 2. 提交记录 /∗两次遍历法∗//*两次遍历法*//∗两次遍历法∗/ /∗一次遍历法∗//*一次遍历法*//∗一次遍历法∗/ 3...
2019-06-21 11:24:47
421
原创 LeetCode-Algorithms-16.最接近的三数之和(C)
1. 题目描述 给定一个包括 n 个整数的数组 nums 和 一个目标值 target。找出 nums 中的三个整数,使得它们的和与 target 最接近。返回这三个数的和。假定每组输入只存在唯一答案。 例如,给定数组 nums = [-1,2,1,-4], 和 target = 1. 与 target 最接近的三个数的和为 2. (-1 + 2 + 1 = 2). 2. 提交记录 3. ...
2019-06-14 15:48:05
276
原创 LeetCode-Algorithms-14. Longest Common Prefix(最长公共前缀)
1. 题目描述 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 示例 1: 输入: ["flower","flow","flight"] 输出: "fl" 示例 2: 输入: ["dog","racecar","car"] 输出: "" 解释: 输入不存在公共前缀。 说明:所有输入只包含小写字母 a-z 。 2. 提交记录...
2019-05-22 23:14:53
237
原创 LeetCode-Algorithms-12.整数转罗马数字
1.题目描述 罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。 字符 数值 I 1 V 5 X 10 L 50 C 100 D 50...
2019-05-21 20:40:27
262
原创 LeetCode-Algorithms- 11.盛水最多的容器(C)
1.题目描述 给定 n 个非负整数 a1,a2,…,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。 找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 说明:你不能倾斜容器,且 n 的值至少为 2。 图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7]。在此情况下,容器能...
2019-05-20 18:11:19
425
原创 LeetCode-Algorithms-8.字符串转换为整数 (atoi)
/* 1. 题目描述 */ 请你来实现一个 atoi 函数,使其能将字符串转换成整数。 首先,该函数会根据需要丢弃无用的开头空格字符,直到寻找到第一个非空格的字符为止。 当我们寻找到的第一个非空字符为正或者负号时,则将该符号与之后面尽可能多的连续数字组合起来,作为该整数的正负号;假如第一个非空字符是数字,则直接将其与之后连续的数字字符组合起来,形成整数。 该字符串除了有效的整数部分之后也可能...
2019-05-19 19:13:00
256
原创 LeetCode-Algorithms-13.Roman to Integer(罗马数字转整数)
/* 1. 题目描述 */ 罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如, 罗马数字 2 写做 I...
2019-05-18 21:45:57
245
原创 LeetCode-Algorithms-9.Palindrome Number(回文数):
9.Palindrome Number(回文数)©: 1. 题目描述: 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 示例 1: 输入: 121 输出: true 示例 2: 输入: -121 输出: false 解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。 示例 3: 输入: 10...
2019-05-18 12:20:27
308
原创 LeetCode-Algorithms-7.Reverse Integer(数字反转):
LeetCode-Algorithms-Reverse Integer(数字反转)©: 给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。 示例 1: 输入: 123 输出: 321 示例 2: 输入: -123 输出: -321 示例 3: 输入: 120 输出: ...
2019-05-17 17:55:57
233
原创 Shell插入排序(c语言版)
#include #include #define M 30 /*算法思想: 对数据进行按一定规则不断分组,在每一组利用直接插入排序进行排序的基础上,实现Shell插入排序; 具体操作: 对n个数据进行排序,首先取1个正整数d 然后对这组数据进行直接插入排序,不断进行这个操作直至d=1结束 */ /*Shell插入排序函数:比直接插入排序效
2015-12-20 19:13:21
840
原创 直接插入排序(c语言版)
#include #include #define M 30 /*算法思想: 把数据分为数据分为有序集和无序集,默认第一个数是有序集; 用无序集中的数依次和无序集中的数比较,如果不满足条件(升序或者降序) 找到无序集中的数应该插入有序集的位置,实施插入;如果满足条件则继续遍历下一个无序集中的数 */ /*升序排序函数*/ void insert
2015-12-20 18:50:01
693
原创 尾插法创建带头结点单链表(c语言版)
#include #include typedef struct k{ int data; struct k* next; }Node; /*创建链表*/ Node* initList(){ /*初始化*/ Node *h=(Node *)malloc(sizeof(Node)); h->next=NULL; retu
2015-12-16 21:33:27
4696
2
原创 创建二叉排序树并查找值为x的节点(c语言版)
#include #include /*所谓二叉排序树,即左子树的值小于根节点,右子树的值大于根节点;中序遍历的结果从左到右为升序*/ typedef struct node { int data; struct node *lchild; struct node *rchild; }node; /*查找x*/ /*算法思想: 查找x的结果有
2015-12-13 21:55:53
3299
原创 线性表排序(C语言版)
#include #include #define MAXSIZE 100 typedef int datatype; typedef struct{ datatype size; int a[MAXSIZE]; }seqlist; void init(seqlist *L){ L->size=0; } void input(seqlist *L)
2015-11-30 22:03:14
1307
原创 线性表转置
/*将线性表就地转置,思想:头尾交换*/ #include #define M 100 //定义顺序表 typedef struct { int len; int a[M]; }SeqList; //线性表初始化 void init_posList(SeqList *L){ L->len = 0; } //插入x到L->a[i] int inse
2015-11-30 21:59:46
956
1
原创 递归-奇数放左边,偶数放右边
#include #include #include #define N 10 void input(int a[],int n){/*长度为n的整型数组作输入*/ int i; printf("请输入%d个整数:\n",n); for(i=0;i scanf("%d",&a[i]); } void print(int a[],in
2015-11-30 21:54:10
1928
1
原创 凹入表示法(C语言版)
#include #include #define m 3 typedef struct k{ char data; struct k *child[m]; }tree; /*前序遍历建树*/ tree *createTree() { tree *t; /*1、如果是‘#’则return;*/ char x=getchar();
2015-11-30 21:48:39
7862
2
原创 后序遍历首尾点(C语言版)
#include #include typedef struct tree { char data; struct tree*lchild,*rchild; }bintree; typedef bintree *tree; //ABD#E##FG###C## //后序遍历:EBGFBCA tree createtree(tree t) { char c=ge
2015-11-30 21:44:12
464
原创 中序遍历非递归算法(C语言版)
#include #include #define M 100 //前序遍历:ABD#E##FG###C## typedef struct tree/*二叉树*/ { char data; struct tree *lchild,*rchild; }bintree; typedef bintree *tree; tree createTree()/*前序遍历建树*
2015-11-30 21:39:34
5223
原创 非递归前序遍历建树并查找首点尾点
#include #define M 100 typedef struct tree{ char data; struct tree *lchild,*rchild; }bintree; /*定义树*/ typedef bintree *tree; //ABD#E##FG###C## /*前序遍历建树*/ tree createTree() {
2015-11-30 21:33:06
500
原创 树的括号表示法(C语言版)
#include #include #define M 4 //AB####CF####H######D####E#### typedef struct k{ char data; struct k *child[M]; }tree; /*前序遍历建树*/ tree *createTree() { tree *t;int i; char
2015-11-30 21:25:29
3186
原创 稀疏矩阵的快速转置(C语言版)
#include #include #define MAX 100 typedef struct node{ int i,j,v; }SYZ; void createlist(SYZ *L,SYZ a[MAX],int x,int y,int z){ int n=0; a[n].i=x; a[n].j=y; a[n].v=z; n++;
2015-11-30 21:10:34
11523
CodeBlocks 17.12 & 编译器.rar
2019-05-12
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅