- 博客(23)
- 收藏
- 关注
原创 IP地址
IP地址是指互联网协议地址(Internet Protocol Address) IP地址有三种基本类型,由网络号的第一组数字来表示。 三种基本类型分别为A类,B类,C类。 另外还有D类,和E类。 现在IP地址使用点分十进制表示。地址格式为: IP地址 = 网络地址 + 主机地址 或者 IP地址 = 主机地址 + 子网地址 + 主机地址1、A类地址 一个A类IP地址由一
2016-07-03 00:41:04
458
转载 sicily Tiling a Grid With Dominoes
题意: 问一个 L*4 的矩形,用2*1的小矩形组成有多少种组法。思路: 递推。用一个4bit的整数表示“行状态”。写出15个递推式即可。首先,定义 f [ i ] [ j ] 为, 已组成长度 (i - 1)* 4 的完美矩形, 第 i 行的状态是 j (0~15)的方案数。那么我们可以考察 f [ i ] [ j ] 可以怎么求得。注意下面的状态方程的推导,围绕的思路不仅是要填满 15(1
2016-06-06 11:44:05
502
原创 gradient()函数的理解
梯度:变化/参考量 gradient()是求数值梯度函数的命令。 [Fx,Fy]=gradient(x),其中Fx为其水平方向上的梯度,Fy为其垂直方向上的梯度,Fx的第一列元素为原矩阵第二列与第一列元素之差,Fx的第二列元素为原矩阵第三列与第一列元素之差除以2,以此类推:Fx(i,j)=(F(i,j+1)-F(i,j-1))/2。最后一列则为最后两列之差。同理,可以得到Fy。1。如果F是一维矩
2016-05-18 22:29:31
21626
原创 imfilter()函数的用法
功能:对任意类型数组或多维图像进行滤波。用法:B = imfilter(A,H) B = imfilter(A,H,option1,option2,…) 或写作g = imfilter(f, w, filtering_mode, boundary_options, size_options) 其中,f为输入图像,w为滤波掩模,g为滤波后图像。filtering_mode用于指定在滤
2016-05-18 22:18:05
1326
原创 fspecial()函数解析
今天来总结一下fspecial()函数用法: h = fspecial(type) h = fspecial(type,para) h = fspecial(type, pare, sigma) 其中type指定算子的类型,pare指定相应的参数,sigmasigma表示滤波器的标准差,单位为像素,默认值为0.5。1、’average’ 为均值滤波,参数为hsize代表模板尺寸,默认值为【
2016-05-18 22:12:12
3814
转载 Matlab显示图像问题,double处理后,图像变白
在matlab中,我们常使用imshow()函数来显示图像,而此时的图像矩阵可能经过了某种运算。在matlab中,为了保证精度,经过了运算的图像矩阵I其数据类型会从unit8型变成double型。如果直接运行imshow(I),我们会发现显示的是一个白色的图像。这是因为imshow()显示图像时对double型是认为在0~1范围内,即大于1时都是显示为白色,而imshow显示uint8型时是0~25
2016-05-18 20:28:54
2456
原创 Printing numbers in a pyramid pattern(一)
Description Write a program that reads an interger n, then display one of the following patterns. Pattern 1 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6Pattern 2 1 2
2016-04-26 09:48:26
1030
原创 Yaroslav and Permutations
Description Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring el
2016-04-25 01:36:29
465
原创 博弈论问题
一、巴什博奕(Bash Game) 只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个.最后取光者得胜. n = (m+1)r+s , (r为任意自然数,s≤m), 即n%(m+1) != 0, 则先取者肯定获胜。 代码实现 ,判断先取者是否能够取胜。bool isWin(int n, int m){ if(n % (m + 1) != 0)
2016-04-20 20:48:18
601
原创 求链表中奇数位置上的和
给出一个链表,每个节点有一个数值,你需要返回链表奇数位置的数值之和,位置从1开始计数。例如链表为1->2->4->5->6你需要返回11include include using namespace std;struct ListNode{ int val; ListNode *next; ListNode():val(0), next(NULL){}; Li
2016-04-18 20:37:03
862
原创 T-Prime(数学规律)
Description We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we’ll call a positive integer t Т-prime, if t has exactly three distinct posit
2016-04-16 18:50:20
1645
原创 Elements and MyVector
Description 实现类Elements 和 MyVector中的成员函数,完善这两个类。注意,只要提交类的实现,不需要提交类的声明。class Elements{ private: int value; static int numberOfObjects; public: Elements(); Elemen
2016-04-15 02:27:32
392
原创 the number of position
Description Jesse stands in line of n people, but he doesn’t know exactly which position he occupies. He can say that there are no less than A people standing in front of him and no less than B people
2016-04-14 10:17:14
492
原创 判断两个字符串是不是互为anagrams
Description Write a function that checks whether two words are anagrams. Two words are anagrams if they contain the same letters in any order. For example, “silent” and “listen” are anagrams. The head
2016-04-12 10:07:12
1902
原创 将十六进制字符串转换成十进制数字
Write a function that parses a hex number as a string into a decimal integer.The function header is as follows: int parseHex(const char * const hexString) For example, hexString “A5” is 165 (10*16+5=16
2016-04-12 09:39:52
3051
原创 对象数组
Description 建立一个对象数组,内放五个学生的数据(学号、成绩),用指针指向数组首元素,输出第1,3,5个学生的数据Input 输入五个学生资料,如下: 1001 98 1002 76 1003 65 1004 90 1005 77Output 输出1,3,5个学生的数据: 1001 98 1003 65 1005 77Sample Input Copy samp
2016-04-12 00:07:24
583
2
原创 建立一个学生类及其相应对象
Description 学生有属性学号,姓名,性别,三个成员,为私有属性;成员函数setdata负责输入学生的信息。成员函数display负责显示学生的信息。Input 输入学生学号、姓名、性别Output 输出学号、姓名、性别Sample Input Copy sample input to clipboard 1000 tan m Sample Output 1000 t
2016-04-11 23:52:20
2194
原创 编写一个基于对象的程序,求长方形的体积
长方柱数据成员包括length、width、height,要求用成员函数实现以下功能: 1,输入3个长方体的长宽高; 2,计算长方柱的体积; 3,输出3个长方体的体积。 Input 1 2 3 3 3 3 10 10 10Output 6 27 1000#include<iostream>using namespace std;class rectangle{ publ
2016-04-11 22:26:42
7681
1
原创 LIS 求最小的最长递增子序列
Description A numeric sequence of ai is ordered if a1 <= a2 <= … <= aN. Let the subsequence of the given numeric sequence (a1, a2, …, aN) be any sequence (ai1, ai2, …, aiK), where 1 <= i1 < i2 < … < i
2016-04-11 10:39:24
649
原创 求两个字符串的最长公共子序列
方法一、递归 采用递归的方法,代码简单,但是速度比较慢,当字符串比较大的时间,多次递归会计算一些重复的过程,因此速度很很慢。方法二、动态规划 可参考博客链接 http://write.blog.youkuaiyun.com/postlist 引进一个二维数组c[][],用c[i][j]记录X[i]与Y[j] 的LCS 的长度,b[i][j]记录c[i][j]是通过哪一个子问题的值求得的,以决定搜索的方向
2016-04-10 22:18:36
1305
原创 各种排序算法
1、冒泡算法//冒泡算法的实现 void puppleSort(int *array, int length){ if(array == NULL || length <= 0){ cout << "input Error!"; } for(int i = 0; i < length-1; ++i){ for(int j = i+1; j <
2016-04-09 23:38:08
295
原创 最小生成树
Description Given n nodes in a two-dimensional space, we want to use single-link custering method to find k clusters. This is equivalent to finding an MST (Minimum spanning tree) of these nodes and de
2016-03-24 16:57:54
471
原创 Fibonacci 数列
方法一、使用递归的方法 求斐波那契第n项! 这种方法虽然代码看起来简单,但是,效率非常低。因为在递归求解的过程中重复计算。long long Fibonacci(unsigned int n){ if(n <= 0) return 0; if(n == 1) return 1; return Fibonacci(n-1) + Fibonac
2016-03-24 16:13:27
343
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人