![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
nujsuez
这个作者很懒,什么都没留下…
展开
-
c 查询整型中1 的个数
#include "stdafx.h"#include #include unsigned int cal(unsigned n){ unsigned c = 0; printf("%x\n",n); while (n>0) { c += n&1; n=n>>1; } return c;}转载 2014-07-28 14:27:15 · 697 阅读 · 0 评论 -
c 取N中最大的K个数
// max_k_number.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include #include using namespace std;void partition(int a[], int s,int t,int &k) {//devide the array into three parts转载 2014-07-28 14:16:37 · 1168 阅读 · 0 评论 -
c++ 删除整形数组中重复的数字
int *RemoveDup(int arr[], int n){ int *tmp = NULL; int *arr_new = NULL; arr_new = (int *)malloc(n*sizeof(int)); tmp = arr_new; set s; pair::iterator, bool> p;// list l; 用list也可以保存 int k = 0;原创 2014-05-12 23:55:12 · 5819 阅读 · 0 评论 -
c 删除字符串中的特殊字符
下面是删除特字符串中的所有空格原创 2014-04-22 15:29:03 · 1159 阅读 · 0 评论 -
c 实现斐波那契(fibonacii)数列
long int fib(long int num){ if(num ==1 || num ==2}原创 2014-04-21 17:37:07 · 1841 阅读 · 0 评论 -
c 判断两个链表是否相交
只需判断两个链表是否有共同结点。1. 如果两个原创 2014-04-21 16:21:12 · 841 阅读 · 0 评论 -
c 判断链表是否有环,以及环上结点数
给一个头指针head,判断链表LinkNode 是否有环,环上结点数void IsLinkLoop(LinkNode *head){ if (head ==NULL) { return NULL; } LinkNode *p=head, *q = head; bool isLoop = false; while(q && q->next) { p = p->n原创 2014-04-21 15:18:18 · 876 阅读 · 0 评论 -
求1+2+3+..+n 和1*2*3*...*n递归
UINT sum(UINT num){ return (num==0)?0:(num+sum(num-1));}UINT factorial(UINT num){ return (num==1) ? 1:(num*factorial(num-1));}原创 2013-05-10 11:12:22 · 1523 阅读 · 0 评论 -
实现单链表创建、插入、删除、打印功能
// ChainSample.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include typedef struct ChainNode{ int num_value; struct ChainNode *next;} STRU;STRU* CreatChain(int n){//创建单链表,返回头指针原创 2013-04-03 16:51:35 · 977 阅读 · 0 评论 -
递归通俗解释
递归通俗解释:你可以把递归看做到楼顶取东西。从一楼爬,看,不是的,继续爬,每层楼梯看上去都一样,你执行的过程都一样,但是实际上,1到2,2到3的楼梯是两个楼梯,等你到楼顶了,取了东西,你不能直接就跳楼,还得从楼顶一层层退回来。就像皇帝叫大臣做一件事,然后大臣再叫知县去做,知县办好了,上报大臣,大臣处理完再上报皇帝。转载 2013-01-19 16:26:05 · 4812 阅读 · 0 评论 -
二叉树前序,中序,后序遍历详解
只要是搞计算机的,对数据结构中二叉树遍历都不陌生,但是如果用到的机会不多那么就会慢慢淡忘,温故而之新才是最好的学习方式,现在就重新温习一下这方面的知识。首先我想先改变这几个遍历的名字(前根序遍历,中根序遍历,后根序遍历);前中后本来就是相对于根结点来说的,少一个字会产生很多不必要的误解。 1. 前根序遍历:先遍历根结点,然后遍历左子树,最后遍历右子树。ABDHECFG2.原创 2012-07-09 15:28:13 · 68584 阅读 · 4 评论 -
next数组的求解思路
void makeNext(const char P[],int next[]){ int q,k;//q:模版字符串下标;k:最大前后缀长度 int m = strlen(P);//模版字符串长度 next[0] = 0;//模版字符串的第一个字符的最大前后缀长度为0 for (q = 1,k = 0; q < m; ++q)//for循环,从第二个字符开始,依转载 2015-05-07 11:54:42 · 697 阅读 · 0 评论