#include <stdio.h> int main() { int n,i,j,item,arr[50000] = {0},m = 0; while(scanf("%d", &n) != EOF)…
数组
1、有n个数,两两组成二元组,差最小的有多少对呢?差最大呢? 解析:先排序,差最大的对数为最小数字的个数*最大数字的个数 差最小为分两种情…
大数相加
#include <stdio.h> #include<string.h> #include <stdlib.h> #define MAX 101 void bigDataAdd(ch…
两栈共享空间
/* 两栈共享空间 */ //存储结构定义 const int StackSize = 10; typedef int DataType; typedef struct { Data…
算术表达式求值
计算3*(4+2)/2-5的值 #include <stdio.h> #include <string.h> int Comp(char str1,char str2); int Compute(…
连连看自动查找核心算法
#include <stdio.h> #include <windows.h> #include <iostream> #include <list> using name…
堆排序,用一种清新脱俗的方式
最近用OC写算法时遇到这么一道题: 问题:给定一个字符数组,判断字符数组中是否所有的字符只出现过一次,如果是,那么返回yes,否则返回no。 第一种解法很简单,我们通过开辟空间创建Hash表比较即可,代码如下: BOOL…
多维数组------八皇后问题
/* 八皇后问题 在8*8的棋盘上摆放8个皇后,不能处于一排一列或者一斜线上,,使其不能相互攻击 */ #include <stdio.h> #include <math.h> &nbs…
栈的链接存储结构及实现
/*栈的链接存储结构及实现*/ //初始化栈 void InitStack(Node *top) { top = NULL; } //入栈操作 void Push(Node *top…
医院选址问题
/* 医院选址问题 在五个村庄之中选一个建立医院,要求各个村庄往返路程越短越好,最好应该选在何处 有向网的邻接矩阵 0 13 M 4 M 13 0 15&nbs…
循环队列的顺序存储结构及实现
/*循环队列的顺序存储结构及实现*/ //存储结构定义 const int QueueSize = 10; //定义数组最大长度 typedef …
哈夫曼树
#include const int n = 5; typedef struct { int weight; int parent,lchild…