![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C语言
文章平均质量分 81
tjyyyangyi
这个作者很懒,什么都没留下…
展开
-
[C语言]双链表各种基本操作
#include typedef struct doubleLink { int data; struct doubleLink *pre; struct doubleLink *next; }dnode; //建立链表 dnode* createDLink() { dnode *head,*p原创 2012-08-01 16:15:19 · 4658 阅读 · 0 评论 -
[C语言]背包问题
0-1背包问题 参考:http://blog.csdn.net/liwenjia1981/article/details/5725579http://blog.csdn.net/dapengbusi/article/details/7463968动态规划解法借个图 助于理解从背包容量为0开始,1号物品先试,0,1,2,的容量都不能放.所以置0,背包容量为3则里面放4原创 2012-08-31 15:54:44 · 30198 阅读 · 3 评论 -
[C语言]字符的排列和组合
1、字符的排列输入:abc输出:abc acb bac bca cab cba#include#include#includevoid mySwap(char *a,char *b){ char temp; temp = *a; *a = *b; *b = temp;}void PaiLie(char *list,int begin,in原创 2012-08-25 13:28:02 · 4353 阅读 · 0 评论 -
[C语言]KMP算法
#include#includeint next[100];char p[100] = "ababa"; //匹配串char s[100] = "ababcababa"; //源串void getNext(char *cmp){ int k = -1; int j = 0; next[j] = k; while(cmp[j] != '\0')原创 2012-09-05 22:38:00 · 777 阅读 · 0 评论 -
[C语言]循环链表及出圈问题
使用循环链表解决出圈问题:#includetypedef struct cycleLink{ int data; struct cycleLink *next;}cNode;//建立循环链表cNode* createCycleLink(int n){ cNode *current,*p; int i; if(n<1) return NULL;原创 2012-08-02 00:28:11 · 1588 阅读 · 0 评论 -
[C语言]二叉树(建树、是否相等、三种遍历)
(注:题目是借来的,代码是自己写的,已通过VC编译,并正确运行) A、B两棵树相等当且仅当RootA->c==RootB->c,而且A和B的左右子树对应相等或者左右互换后相等。#include#includetypedef struct treeNode{ struct treeNode *left,*right; int data;}treeNode;原创 2012-08-16 23:03:31 · 3504 阅读 · 0 评论 -
[C语言]队列基本操作
#includetypedef struct dataNode{ int data; struct dataNode *next;}qNode;typedef struct linkQueue{ qNode *head; qNode *tail;}linkQueue;//创建一个新队列linkQueue* createLinkQueue()原创 2012-08-02 12:55:57 · 2797 阅读 · 0 评论 -
[C语言]栈的基本操作 使用两个栈模拟队列
#include#include typedef struct stackNode{ int data; struct stackNode *next;}sNode;typedef struct myStack{ sNode *bottom; sNode *top;}myStack;//建立栈myStack* createStack()原创 2012-08-02 16:22:13 · 1050 阅读 · 0 评论 -
[C语言]字符串的各种问题
1、将一句话里的单词进行倒置,以单词为单位。 写了两种方法,第一种借用的辅助空间过大,第二种辅助空间小。#include#include#include char* reverseByWords(char* s){ char *temp; int i,j,len; int newL,oldL,oldR; //newL表示新字符串中左边的指针 /原创 2012-08-06 00:20:51 · 593 阅读 · 0 评论 -
[C语言]strcat strstr strcpy strcmp strlen 的实现与使用
函数名:strcat 功能:把src所指字符串添加到dest结尾处(覆盖dest结尾处的'\0')并添加'\0'。说明:src和dest所指内存区域不可以重叠且dest必须有足够的空间来容纳src的字符串。 返回:指向dest的指针。int main(){ char *MyStrcat(char * dest, const char * src); char a[30]原创 2012-07-03 00:44:43 · 1370 阅读 · 0 评论 -
[C语言]求二叉树节点最大距离(C、JAVA 递归、非递归)
求二叉树节点最大距离注:C语言的两种实现代码参考了前辈的文章, JAVA为原创,4段代码均运行通过 C语言 递归实现#include#include //求二叉树节点最大距离 //C语言 递归实现typedef struct node{ struct node *left; struct node *right; int maxLeft; int原创 2012-08-11 19:07:34 · 1816 阅读 · 0 评论 -
[C语言]寻找有环单链表的环入口,寻找两个相交链表的相交点
1、寻找有环单链表的环入口(注:此处思想和部分代码借鉴前辈的,进行了完善,完成了从建立有环链表到最后输出环入口的所有代码,运行结果正确)设置两个指针(fast, slow),初始值都指向头,slow每次前进一步,fast每次前进二步,如果链表存在环,则fast必定先进入环,而slow后进入环,两个指针必定相遇。当fast若与slow相遇时,slow肯定没有走遍历完链表,而fast已经在原创 2012-08-11 22:43:55 · 825 阅读 · 0 评论 -
[C语言]各种经典排序
void swap1(int *a,int *b){ int temp = *a ; *a = *b; *b = temp;}//冒泡排序void BubbleSort(int *a,int size){ int i,j; for(i=0;i<size;i++) for(j=size - 1; j > i; j--) if(a[j] < a原创 2012-07-31 00:55:42 · 833 阅读 · 0 评论 -
[C语言]单链表各种基本操作
#includetypedef struct student{ int data; struct student *next;}node;//链表建立node* create(){ node *head,*p,*s; int x; head = (node*)malloc(sizeof(node)); p = head; while(1原创 2012-08-01 12:54:19 · 897 阅读 · 0 评论 -
[C语言]基数排序
#includevoid radixSort(int *a,int size){ int temp[10][20]={0}; //第一个10表示0~9,第二个20表示a的size int order[10]={0}; int i,j,k; //k表示当前比较的那一位上的具体数字 int n; //n=1,10,100,1000...取决于a中的最大的数 in原创 2012-09-11 23:55:45 · 2331 阅读 · 0 评论