- 博客(84)
- 资源 (2)
- 收藏
- 关注
原创 二叉树转换成双向链表
二叉树转换成双向链表题目: 将一个搜索二叉树转换成一个有序的双向链表思路: 具体用递归的思想,用当前函数的指针节点与左子树的双向循环链表的尾节点进行指针的指向更新,当前的指针节点与右子树的双向循环链表的头结点进行指针的指向更新,最后递归函数返回值为当前形成的双向循环链表的尾节点。 具体代码如下:#include <iostream> #include <queue> #include <alg
2016-07-31 18:21:50
642
原创 2016.4.3腾讯笔试编程题
1. 蛇形矩阵题目大意:给一个边长n,给出1-n^2的数字蛇形数据,如下 n=3 ⎡⎣⎢187296345⎤⎦⎥ \begin{bmatrix} 1 & 2 & 3 \\ 8 & 9 & 4 \\ 7 & 6 & 5 \end{bmatrix} output:1 2 3 8 9 4 7 6 5#include <stdio.h> #include <string.h
2016-04-04 14:49:34
1081
原创 JPEG图像获取GPS数据
背景周一来到实验室本来要做项目,这个月快到月底了,想赶快写,要不然导师就要催。导师突然交给任务,让完成一个基于c++的JPEG图像获取GPS数据的小程序,他说很小,很简单,让我赶快写。让我做的事情如下图: 就是要获取如图所示的GPS数据。TUA,我哪会啊,根本是一头雾水啊,但是还是给应承下来。准备工作我准备了两个步骤: 如何实现多文件选取的功能,将获取到的图像文件绝对路径存储; 如何对每个图像
2015-10-26 21:09:57
3257
3
原创 范围查询(Range)-----学堂在线编程题
题目(请点我)描述 数轴上有n个点,对于任一闭区间 [a, b],试计算落在其内的点数。输入 第一行包括两个整数:点的总数n,查询的次数m。第二行包含n个数,为各个点的坐标。以下m行,各包含两个整数:查询区间的左、右边界a和b。输出 对每次查询,输出落在闭区间[a, b]内点的个数。样例 Input 5 2 1 3 7 9 11 4 6 7 12 Output 0 3思路由于题目限制时间和内存,所以
2015-10-02 13:36:16
3559
原创 动态规划之LIS && ZigZag && BadNeighbors
题目背景 第一个LIS,最长非递减序列,这个大家应该很熟悉了吧。不用具体叙述。 第二个是TopCoder中的题目,附上网址,请点击我 理由为什么将两者结合一起,主要是因为,所用的方法是在本质上是一样的。 首先说一下题目特征: 首先都是在一维的层次上,属于初级递推公式 都是以数组a[]作为输入,阶段的划分是以离散时间作为节点,在这两个程序中,我用的都是dp[]作为递推的结果记录,记录每个节点的最长纪
2015-09-19 17:01:18
1261
原创 2015.9.17 杂知识随笔
今天的一些小问题思考 今天写mfc程序的时候, 总是提示glu.lib找不到,无法链接,我当时一直在想到底在什么地方调用这个lib, 后来找到项目属性->连接器->输入中,由于程序为别人的程序,所以他链接的为这个lib库,而我改成了glu32.lib库后,成功运行。 明天打算考虑用Osg NURBS 做地表曲面,还要求地表面积,希望明天半天完成。
2015-09-17 21:58:27
556
原创 第一章 绪论
课堂的相关问题记录 级数的相关知识,如算数级数、幂方级数,几何级数,收敛级数等,如下图: 具体相关书籍请参阅《concrete mathentics》 将数量级与二位图像结合记忆 算法的正确性:不变性, 单调性(规模是减少的) 1天 约等于 10 ^ 5sec 递归用到减而治之的方法(decrease && conquer)(如整数求和的问题); 思想: 将问题化为平凡问
2015-09-17 21:48:45
455
原创 算法导论/6.2保持堆性质
保持堆性质的递归与迭代源程序源代码代码块代码块语法遵循标准markdown代码,例如:/* * 算法导论/6.2保持堆性质的实现 * 2015.9.10 by Bean * */#include <stdio.h>/** * LEFT - 求左子节点的序号 * @parent 父节点的序号 */ int LEFT(int parent);/** * RIGHT -
2015-09-10 21:42:06
564
原创 活动安排-动态规划算法
#include <stdio.h> #include <stdlib.h>#define MAX 100typedef struct arrangement{ int s; int f; }arrangement;int cmp(const void *a, const void *b) { arrangement *m = (arrangement *)a; ar
2015-07-17 15:25:05
1670
1
原创 SCIP2.41
SICP 2.41SICP 241 题目叙述 思路分析 引子 题目解答 结语题目叙述 读写出一个过程,他能产生出所有小于等于给定整数你的正的相异整数i、j和k的有序三元组,使每个三元组的三个元之和的等于给定的整数s。 思路分析引子给定一个序列没希望生成这种序列的所有的排列形式,类似于全排列。例如'(1 2 3)生成的排列形式如下: (1 2 3)
2015-04-23 15:15:30
1198
原创 当风起时,我希望有一个坚强的躯干
从十月二十号开始,就开始迷茫自己该做些什么,做事情能做到什么程度才算好,一直以一个自认为“很完美的标准”去约束自己,殊不知正式因为这些所谓的“完美的标准”深深的阻挡着自己的前进的脚步,每当自己似乎要跨出一步的时候,又被这些所谓的标准吓得止于第一步,甚至连半步都没有跨出过,自己博客中的十月二十号开始的博客中添加了几个分类,当时看了刘伟鹏的暗时间所讲的为什么要写博客的看法而萌发的一个想法,而自己总认为
2014-12-23 14:06:20
722
原创 题目1124:Digital Roots
点击打开链接 /* 时间:2014.2.16 目次: 题目1124:Digital Rootsac.jobdu.com/problem.php?pid=1124 */ #include #include int main() { char str[10001]; int i, t; while(~scanf("%s", str), str[0] - '0') { while
2014-02-16 14:17:35
1300
原创 题目1508:把字符串转换成整数
点击打开链接/* 时间:2014.2.11 目的:题目1508:把字符串转换成整数ac.jobdu.com/problem.php?pid=1508 */ #include int main() { char str[10]; int i, flag, ans, f, ff; while(~scanf("%s", str)) { f = ff = ans = flag = 0;
2014-02-11 15:28:37
1128
原创 题目1175:打牌
点击打开链接 /* 时间:2014.2.10 目的;题目1175:打牌http://ac.jobdu.com/problem.php?pid=1175 */ #include #include int main() { char str[101]; int a[10], i, len, t, f, flag; while(~scanf("%s", str))
2014-02-10 14:36:43
1348
原创 题目1511:从尾到头打印链表
点击打开链接 /* 时间:2014.2.7 目的: 题目1511:从尾到头打印链表ac.jobdu.com/problem.php?pid=1511 */ #include #include typedef struct LinkNode{ struct LinkNode*prior; struct LinkNode*next; int data; }LinkNode,*L
2014-02-07 12:54:43
983
原创 题目1184:二叉树遍历
点击打开链接 /* 时间:2014.2.6 目的:题目1184:二叉树遍历ac.jobdu.com/problem.php?pid=1184 */ #include #include #include char str[101]; typedef struct TreeNode{ struct TreeNode *left; struct TreeNode *right;
2014-02-06 20:28:18
1350
原创 题目1076:N的阶乘
点击打开链接 /* 时间:2014.2.6 目的: 题目1076:N的阶乘http://ac.jobdu.com/problem.php?pid=1076 */ #include int a[26000]; int main() { int n, i, j, len, t; while(~scanf("%d", &n)) { if(n==0)//小细节需要考虑0的!=1
2014-02-06 19:55:06
1870
原创 题目1179:阶乘
点击打开链接 /* 时间:2014.2.2 目的:题目1179:阶乘 http://ac.jobdu.com/problem.php?pid=1179 */ #include long long int fun(int n) { if(n==1) return 1; else return n*fun(n-1); } int main() { long long i
2014-02-02 11:45:52
666
原创 题目1181:遍历链表
点击打开链接 /* 时间:2014.2.2 目的: 题目1181:遍历链表http://ac.jobdu.com/problem.php?pid=1181 */ #include #include #include int cmp(const void *a,const void *b) { return *(int*)b-*(int*)a; } typedef struct Li
2014-02-02 10:48:55
1140
原创 题目1180:对称矩阵
点击打开链接 /* 时间:2014.2.2 目的: 题目1180:对称矩阵 */ #include int main() { int n,i,j,f,a[100][100]; while(~scanf("%d", &n)) { f=1; for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%d", &a[i][j]); for(
2014-02-02 10:20:15
715
原创 题目1183:守形数
点击打开链接 /* 时间:2014.2.1 目的:题目1183:守形数ac.jobdu.com/problem.php?pid=1183 */ #include int main() { int n,t; while(~scanf("%d", &n)) { t = n*n; while(t&&n) { if(t%10!=n%10) break; t
2014-02-01 23:05:22
1272
原创 题目1182:统计单词
点击打开链接 /* 时间:2014.2.1 目的: 题目1182:统计单词ac.jobdu.com/problem.php?pid=1182 */ #include int main() { char s[200]; int i,cnt; while(gets(s)) { cnt = 0; for(i=0;s[i];i++) { if(s[i] == ' '
2014-02-01 21:56:06
1183
原创 题目1187:最小年龄的3个职工
点击打开链接 /* 时间:2014.2.1 目的:题目1187:最小年龄的3个职工http://ac.jobdu.com/problem.php?pid=1187 */ #include #include #include typedef struct ZG{ int ID; char name[11]; int age; }ZG; ZG zg[30]; int cmp(c
2014-02-01 21:15:44
1129
原创 题目1186:打印日期
点击打开链接 /* 时间:2013.2.1 目的:题目1186:打印日期http://ac.jobdu.com/problem.php?pid=1186 */ #include int Month[13] = {13,31,28,31,30,31,30,31,31,30,31,30,31}; int main() { int year, day, i; int ye[4],yu[2],
2014-02-01 18:38:35
1045
原创 题目1201:二叉排序树
点击打开链接 /* 时间:2014.1.31 目的:题目1201:二叉排序树 http://ac.jobdu.com/problem.php?pid=1201 */ #include #include struct TreeNode{ struct TreeNode *left; struct TreeNode *right; int data; }; void
2014-01-31 20:33:59
1161
原创 题目1200:最大的两个数
点击打开链接 /* 时间:2014.1.31 目的:题目1200:最大的两个数 http://ac.jobdu.com/problem.php?pid=1200 */ #include void fun(int *a,int b)//核心代码 { int f1=0; if(a[0] > a[1]) f1 = 1;//判断f1==1表示a[0]>a[1] else if(a[0
2014-01-31 15:48:00
1244
原创 题目1199:找位置
点击打开链接 /* 时间:2014.1.31 目的:题目1199:找位置 http://ac.jobdu.com/problem.php?pid=1199 */ #include #include int main() { char str[101]; int flag[101], i, j, k, f; while(gets(str)) { memset(flag,0,si
2014-01-31 12:57:34
1214
原创 题目1190:大整数排序
点击打开链接 /* 时间:2014.1.30 目的:题目1190:大整数排序 */ #include #include #include struct string{ int len; char str[1005]; }; int cmp(const void *a, const void *b) { struct string *s1 = (stri
2014-01-30 08:35:41
1600
原创 题目1191:矩阵最大值
点击打开链接 /* 时间:2014.1.29 目的:题目1191:矩阵最大值 http://ac.jobdu.com/problem.php?pid=1191 */ #include #include int main() { int m, n, i, j, cnt; int p[105][105]; int max, flag; while(~scanf("%d%d",
2014-01-29 11:30:38
1128
原创 2746:约瑟夫问题(猴子选大王)
点击打开链接 /* 目的:模拟猴子选大王 时间:2014.1.21 */ #include #include #include int main() { int n, m, t, i, j; int *p; while(~scanf("%d%d", &n, &m),m||n) { p = (int*)malloc(sizeof(int)*(n+1)); memse
2014-01-21 16:59:48
1263
原创 题目1195:最长&最短文本
/* 时间:2014.1.20 目的:题目1195:最长&最短文本 ac.jobdu.com/problem.php?pid=1195 */ #include #include struct String{ char s[1001]; int len; }string[1001]; int main() { int MAX = -1; int MIN = 1001; int
2014-01-20 10:20:19
881
原创 题目1198:a+b
点击打开链接 /* 时间:2014.1.16.22.00 目的:大数求和 */ #include #include char a[1001],b[1001]; int c[1001]; int main() { int carr,len_a,len_b,i,j,temp,len; while(~scanf("%s %s", a, b)) { carr = len =0;
2014-01-16 22:08:14
1049
原创 题目1197:奇偶校验
点击打开链接 /* 时间:2014.01.16.7.20 网址:http://ac.jobdu.com/problem.php?pid=1197 目的:题目1197:奇偶校验 */ #include #include main(int i,int j,int k,int asc) { char s[101]; int bin[8]; int cnt; w
2014-01-16 19:30:23
1016
原创 Find The Multiple
点击打开链接 #include int n; long long q[99999999]; void BFS() { int front, rear; front = rear = 0; q[rear]= 1; rear ++; long long top; while(front < rear) { top = q[front]; if(top % n == 0)
2013-04-24 15:06:48
640
原创 N!的最高位
题目传送门 Note:本题直接计算一定会超时,故需要用Stirling公式求其最高位。。。。。。#include #include const double Pi = 3.14159265358979323846; const double E = 2.71828182845904523536; const int m[9] = {1,1,2,6,2,1,7,5,4}; int main
2013-04-05 17:03:52
826
原创 题目1117:整数奇偶排序
题目传送门 #include #include int main() { int a[105]; int x; int i, j; int flag; memset(a,0,sizeof(a)); while(~scanf("%d",&x)) { a[x] = 1; flag = 0; for(i = 1;i <= 9;i ++) { scanf("%d"
2013-04-05 10:19:26
774
原创 题目1177:查找
题目链接 题目很简单,简单的模拟。 #include #include int main() { int n; int i, j; char s[105]; char t[105]; memset(s,0,sizeof(s)); while(~scanf("%s", s)) { scanf("%d", &n); while(n --) { mem
2013-04-04 18:41:06
737
原创 题目1203:IP地址
题目链接 AC代码: #include #include int main() { int n, i, j, flag; char s[20]; memset(s,0,sizeof(s)); scanf("%d", &n); while(n--) { scanf("%s",s); int len = strlen(s); int sum = 0; flag =
2013-04-02 22:54:36
661
原创 题目1051:数字阶梯求和
题目链接 总结:大数相加,用数组模拟。注意最高位有进位就行了。。。。 附上代码一枚: #include #include int main() { int b[10005]; int a, n; int i, j; int flag; while(~scanf("%d %d",&a, &n)) { memset(b,0,sizeof(b));//初始化数值 for
2013-04-02 21:46:31
740
转载 约瑟夫环问题
首先看一看最原始的约瑟夫问题: 1 约瑟夫环(Josephus)问题是由古罗马的史学家约瑟夫(Josephus)提出的,他参加并记录了公元66—70年犹太人反抗罗马的起义。约瑟夫作为一个将军,设法守住了裘达伯特城达47天之久,在城市沦陷之后,他和40名死硬的将士在附近的一个洞穴中避难。在那里,这些叛乱者表决说“要投降毋宁死”。于是,约瑟夫建议每个人轮流杀死他旁边的人,而这个顺序是由抽签决定的
2013-04-02 14:53:40
714
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人