数据结构oj
weixin_45726063
这个作者很懒,什么都没留下…
展开
-
栈的实现
#include"stack.h"#include<malloc.h>#include<assert.h>#include<stdio.h>#include<string.h>void stackInit(stack* ps){ assert(ps); ps->array = (SDataType*)malloc(sizeof(SDataType)* 10); if (NULL == ps->array) { assert原创 2020-08-16 21:03:10 · 67 阅读 · 0 评论 -
链表的实现
#include"list.h"#include<malloc.h>#include<assert.h>#include<stdio.h>SListNode* BuySListNode(SLDataType data){ SListNode* newNode = (SListNode*)malloc(sizeof(SListNode)); if (NULL ==newNode) { assert(0);//调试宏,参数为0触发,非0不会触发 re原创 2020-08-16 10:45:18 · 59 阅读 · 0 评论 -
带头节点的双向循环链表的实现
#pragma once#include <stdio.h>#include <stdlib.h>#include <assert.h>#include <malloc.h>typedef int DataType;typedef struct ListNode{ DataType data; struct ListNode* next; struct ListNode* prev;} ListNode;ListNode *ListIn原创 2020-08-15 19:46:12 · 105 阅读 · 0 评论 -
每日一题:链表oj题
1.找链表倒数第k个节点class Solution {public: ListNode* FindKthToTail(ListNode* pListHead, unsigned int k) { if(NULL==pListHead||k==0) return NULL; ListNode* fast=pListHead; ListNode* slow=pListHead; while(k--) { if(NULL==fast)原创 2020-08-14 11:32:56 · 86 阅读 · 0 评论 -
链表oj题
删除链表中等于给定值 val 的所有节点。struct ListNode* removeElements(struct ListNode* head, int val){ struct ListNode*cur=head; struct ListNode*prev=NULL; while(cur) { if(cur->val==val) { if(cur==head) { head=cur->n.原创 2020-08-13 18:48:42 · 194 阅读 · 0 评论 -
每日一题:数据结构oj题
1.给定一个数组,将数组的元素向右移动k个位置, 其中k 是非负整数#include<windows.h>#include<stdio.h>#pragma warning (disable:4996)int main(){ int k; printf("please input the value of k : \n"); scanf("%d", &k); //输入k int ar[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9,原创 2020-08-13 11:43:22 · 346 阅读 · 0 评论