_DataStructure_C_Impl:循环单链表
摘要://CycList:循环单链表#include#includetypedef int DataType;typedef struct Node{ DataType data; struct Node *next;}ListNode,*LinkList;//创建一个不带头结点的循环单链表LinkL...
阅读全文
posted @
2015-07-31 23:47
_noname
阅读(100)
推荐(0)
_DataStructure_C_Impl:单链表
摘要://线性表的链式存储:单链表#include#includetypedef int DataType;typedef struct Node{ DataType data; //数据域 struct Node *next; //指针域}ListNode,*LinkList;//将单链表初始化为空...
阅读全文
posted @
2015-07-30 23:39
_noname
阅读(140)
推荐(0)
_DataStructure_C_Impl:顺序表
摘要://线性表的顺序存储:顺序表//#pragma once//#ifndef SeqList_H//#define SeqList_H#include#include#define ListSize 100typedef int DataType;typedef struct{ DataType ...
阅读全文
posted @
2015-07-30 02:42
_noname
阅读(117)
推荐(0)
平衡二叉树
摘要://平衡二叉树#include#includestruct TreeNode{ int val; int depth; TreeNode *left,*right;};void computeDepth(TreeNode *root){ int depth; if(root->left!=NUL...
阅读全文
posted @
2015-07-27 22:10
_noname
阅读(88)
推荐(0)
基于递归的二叉树遍历
摘要://基于递归的二叉树遍历#include#includestruct TreeNode{ int val; TreeNode *left,*right;};TreeNode *insertTree(TreeNode *root,int val){ TreeNode *newNode; ...
阅读全文
posted @
2015-07-27 20:50
_noname
阅读(92)
推荐(0)
二叉树的建立
摘要://二叉树的建立#include#includestruct TreeNode{ int val; TreeNode *left,*right;};TreeNode *insertTree(TreeNode *root,int val){ TreeNode *newNode; if(root==...
阅读全文
posted @
2015-07-27 20:22
_noname
阅读(80)
推荐(0)
链表的应用:计算每个作业的运行时间
摘要://链表的应用:计算每个作业的运行时间#include#includestruct Task{ char name[50]; char sDate[15]; char sTime[15]; char eDate[15]; char eTime[15]; int cost; Task *next;...
阅读全文
posted @
2015-07-27 01:23
_noname
阅读(144)
推荐(0)
循环链表:约瑟夫问题
摘要://循环链表#includestruct Monkey{ int ID; Monkey * next;};int main(){ Monkey *link,*monkey,*lastMonkey; int totalMonkeys,stride,count; printf("input tota...
阅读全文
posted @
2015-07-26 23:56
_noname
阅读(114)
推荐(0)
最长公共子序列
摘要://最长公共子序列#include#include#define MAX_LEN 1000char sz1[MAX_LEN];char sz2[MAX_LEN];int aMaxLen[MAX_LEN][MAX_LEN];int main(){ scanf("%s%s",sz1,sz2); wh...
阅读全文
posted @
2015-07-26 22:20
_noname
阅读(69)
推荐(0)
帮助Jimmy
摘要://帮助Jimmy#include#include#include#define MAX_N 1000#define INFINITE 1000000int t,n,x,y,max;struct Platform{ int Lx,Rx,h;};Platform aPlatform[MAX_N+1...
阅读全文
posted @
2015-07-26 20:48
_noname
阅读(136)
推荐(0)
最长上升子序列
摘要://最长上升子序列#include#include#define MAX_N 1000int b[MAX_N+10];int aMaxLen[MAX_N+10];int main(){ int N; int i=0,j=0; scanf("%d",&N); for(i=1;ib[j]){ ...
阅读全文
posted @
2015-07-26 00:50
_noname
阅读(74)
推荐(0)
数字三角形
摘要://数字三角形 /*#include#define MAX_NUM 100int D[MAX_NUM+10][MAX_NUM+10];int N;int MaxSum(int r,int j){ if(r==N) return D[r][j]; int nSum1=MaxSum(r+1,j);...
阅读全文
posted @
2015-07-26 00:06
_noname
阅读(98)
推荐(0)
木棍问题
摘要://木棍问题#include#includebool concatenate(int,int,int,int);int compare(const void *arg1,const void *arg2){ return *(int *)arg2-*(int *)arg1;}int sticks...
阅读全文
posted @
2015-07-24 22:42
_noname
阅读(142)
推荐(0)
八皇后问题
摘要://八皇后问题#include#includeint queenPlaces[92][8];int count=0;int board[8][8];void putQueen(int ithQueen);int main(){ int n,i,j; for(i=0;i<8;i++) { for...
阅读全文
posted @
2015-07-23 21:31
_noname
阅读(102)
推荐(0)
红与黑
摘要://红与黑#includeint W,H;char z[21][21];int f(int x,int y){ if(x=W||y=H) return 0; if(z[x][y]=='#') return 0; else{ z[x][y]='#'; return 1+f(x-1,y)+f...
阅读全文
posted @
2015-07-23 20:10
_noname
阅读(113)
推荐(0)
递归-放苹果
摘要://递归-放苹果#includeint count(int x,int y){ if(y==1||x==0) return 1; if(x<y) return count(x,x); return count(x,y-1)+count(x-y,y);}int main(){ int t,m,n,...
阅读全文
posted @
2015-07-22 23:46
_noname
阅读(110)
推荐(0)
逆波兰表达式
摘要://逆波兰表达式#include#includedouble exp(){ char a[10]; scanf("%s",a); switch(a[0]) { case '+':return exp()+exp(); case '-':return exp()-exp(); case '/...
阅读全文
posted @
2015-07-22 23:05
_noname
阅读(115)
推荐(0)
二叉树
摘要://二叉树#includeint common(int x,int y){ if(x==y) return x; if(x>y) common(x/2,y); else common(x,y/2);}int main(){ int m,n; scanf("%d%d",&m,&n); printf...
阅读全文
posted @
2015-07-22 21:30
_noname
阅读(90)
推荐(0)
菲波那契数列
摘要://菲波那契数列#includeint f(int a){ if(a==1||a==2) return 1; else return f(a-1)+f(a-2);}int main(){ int n; scanf("%d",&n); for(int i=0;i<=n;i++) { int...
阅读全文
posted @
2015-07-22 21:26
_noname
阅读(165)
推荐(0)
优化判断条件的例子:讨厌的青蛙
摘要://优化判断条件的例子:讨厌的青蛙#include#includeint r,c,n;struct PLANT{ int x,y;};PLANT plants[5001];PLANT plant;int myCompare(const void *ele1,const void *ele2);i...
阅读全文
posted @
2015-07-22 20:52
_noname
阅读(147)
推荐(0)
遍历搜索空间的例子:熄灯问题
摘要://遍历搜索空间的例子:熄灯问题 #include int puzzle[6][8],press[6][8]; bool guess() { int c,r; for(r=1;r1) { press[1][c]=0; ...
阅读全文
posted @
2015-07-20 22:18
_noname
阅读(171)
推荐(0)
搜索空间中解不唯一的例子:完美立方
摘要://搜索空间中解不唯一的例子:完美立方#include#includeint main(){ int n,a,b,c,d; long int cube[101]; scanf("%d",&n); for(int i=1;i<=n;i++) cube[i]=i*i*i; for(a=6;a<=n...
阅读全文
posted @
2015-07-20 20:36
_noname
阅读(161)
推荐(0)
数学模型中包括多个变量的例子:称硬币
摘要://数学模型中包括多个变量的例子:称硬币#include#includechar left[3][7],right[3][7],result[3][7];bool isHeavy(char);bool isLight(char);int main(){ int n; char c; scanf(...
阅读全文
posted @
2015-07-15 23:57
_noname
阅读(223)
推荐(0)
简单枚举的例子:生理周期
摘要://简单枚举的例子:生理周期#includeint main(){ int p,e,i,d,j,n=1; scanf("%d%d%d%d",&p,&e,&i,&d); while(p!=-1&&e!=-1&&i!=-1&&d!=-1) { for(j=d+1;j<21252;j++) if...
阅读全文
posted @
2015-07-14 19:58
_noname
阅读(211)
推荐(0)
麦森数
摘要://麦森数#include#include#include#define LEN 125void Multiply(int *a,int *b){ int i,j; int nCarry; int nTmp; int c[LEN]; memset(c,0,sizeof(int)*LEN); fo...
阅读全文
posted @
2015-07-12 21:46
_noname
阅读(122)
推荐(0)
大整数除法
摘要://大整数除法#include#include#define MAX_LEN 200char szLine1[MAX_LEN+10];char szLine2[MAX_LEN+10];int an1[MAX_LEN+10];int an2[MAX_LEN+10];int aResult[MAX_...
阅读全文
posted @
2015-07-12 19:48
_noname
阅读(215)
推荐(0)
大整数乘法
摘要://大整数乘法#include#include#define MAX_LEN 200unsigned an1[MAX_LEN+10];unsigned an2[MAX_LEN+10];unsigned aResult[MAX_LEN*2+10];char szLine1[MAX_LEN+10];...
阅读全文
posted @
2015-07-12 14:43
_noname
阅读(136)
推荐(0)
大整数加法
摘要://大整数加法#include#include#define MAX_LEN 200int an1[MAX_LEN+10];int an2[MAX_LEN+10];char szLine1[MAX_LEN+10];char szLine2[MAX_LEN+10];int main(){ whil...
阅读全文
posted @
2015-07-11 21:45
_noname
阅读(118)
推荐(0)
排列
摘要://排列#include#include#define MAX_NUM 1024int an[MAX_NUM+10];int MyCompare(const void *e1,const void *e2){ return *((int *)e1)-*((int *)e2);}int main(...
阅读全文
posted @
2015-07-10 22:59
_noname
阅读(109)
推荐(0)
显示器
摘要://显示器#include#includechar n1[11]="- -- -----";char n2[11]="| ||| ||";char n3[11]="||||| |||";char n4[11]=" ----- --";char n5[11]="| | | | ";ch...
阅读全文
posted @
2015-07-09 19:47
_noname
阅读(107)
推荐(0)
花生问题
摘要://花生问题#define MAX_NUM 55#include#includeint aField[MAX_NUM][MAX_NUM];int T,M,N,K;int main(){ scanf("%d",&T); for(int i=0;i<T;i++) { scanf("%d%d%d",...
阅读全文
posted @
2015-07-08 23:29
_noname
阅读(145)
推荐(0)
约瑟夫问题
摘要://约瑟夫问题#include#include#define MAX_NUM 300int aLoop[MAX_NUM+10];main(){ int n,m,i; while(1) { scanf("%d%d",&n,&m); if(n==0) break; for(i=0;i<n;i+...
阅读全文
posted @
2015-07-06 21:25
_noname
阅读(92)
推荐(0)
时区间时间的转换
摘要://时区间时间的转换#include#includeint difference(char *zone1,char *zone2){ char zone[32][10]={"UTC","GMT","BST","IST","WET","WEST","CET","CEST","EET","EEST"...
阅读全文
posted @
2015-07-05 17:48
_noname
阅读(228)
推荐(0)
玛雅历
摘要://玛雅历#include#includeconst int NAMELEN=10;char month1[19][NAMELEN]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","ma...
阅读全文
posted @
2015-07-04 23:11
_noname
阅读(216)
推荐(0)