![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
笔记
我在中国学习算法设计与分析数据结构这件事
About我在中国学校算法分析与设计,数据结构,计算机组成原理,数据库,数字图像处理this thing
展开
-
啧啧啧 合并两个单链表 不占用新内存
将链表La和Lb合并为Lc,条件: 不给Lc分配新内存(即调整Lc的指针指向两链表符合条件的节点);主要算法List *T_O(LNode La,LNode Lb,LNode Lc){/*判断两链表是否存在一处拜访完,一处有几个村没拜访的情况,如果有就判断是哪几个村,并挨家挨户拜访*/ if(La==NULL||Lb==NULL){ if(La==NULL&&Lb!=NULL){ Lc=Lb; Lc->n原创 2021-12-08 21:29:59 · 935 阅读 · 0 评论 -
二叉树建立 遍历时出现的问题c
二叉树创建并遍历代码如下#include <stdio.h>#include <stdlib.h>#include <malloc.h>typedef struct btnode {struct btnode*lchild,*rchild;int data; }NODE;main(){ NODE *root=(NODE*)malloc(sizeof(NODE)),*q,n; NODE *create(NODE *p); void p原创 2021-12-03 18:34:10 · 2013 阅读 · 0 评论 -
c 递归查找 数组最大值
/*递归查找*/#include <stdio.h>int main(){ int a[]={1,6,7,8,3,5,4,9}; printf("最大数是:%d\n",max(a,4)); return 0;}int max(int a[],int n){ if(n==0) return a[0]; else{ if(a[n]>max(a,n-1)) return a[n];原创 2021-10-29 18:31:17 · 451 阅读 · 0 评论 -
c 二叉树遍历指定节点输出路径
#include<stdio.h>#include<malloc.h>#include<stdbool.h>#define MaxSize 100typedef char ElemType;typedef struct node{ ElemType data; struct node* lchild; struct node* rchild;}BTNode;// 链栈 typedef struct STACK { char data; s原创 2021-10-21 20:24:14 · 338 阅读 · 0 评论 -
c求最大循环节长度
c求最大循环节长度#include <stdio.h>#include <stdlib.h>int main(){ int i=1,j=10; int n=0; int MaxSum=0,sum=1,MaxNum=0; for(n=i;n<j;n++){ int n1=n; while(n1!=1){ if(n1%2==0){ n1=n1/2;原创 2021-10-16 19:34:05 · 91 阅读 · 0 评论 -
c求逆序对
c求逆序对#include <stdio.h>int main(){ int a[]={3,1,4,5,2}; for(int i=0;i<4;i++){ int n = a[i]; for (int m=i+1;m<5;m++){ int j=a[m]; if(n>j){ printf("<");原创 2021-10-16 19:32:40 · 69 阅读 · 0 评论 -
c求Smith数
c求Smith数#include <stdio.h>int judgePriNum(int num){ //int k=(int)sqrt((double)num); for(int i=2;i<num+1;i++){ if(num%i==0){ return 0; } if(i>num){ return 1; } }}i原创 2021-10-16 19:26:58 · 597 阅读 · 0 评论