摘要:
练习1.41对于一个接受单个参数x的函数f来说,要将它应用多一次的办法是执行以下表达式:(f (f a))由此可得相应的double函数,它接受一个函数f,并且返回一个能将f应用两次的过程:(define (double f)(lambda (x)(f (f x))))(让f作为一个过程)(((...
阅读全文
posted @ 2015-02-17 20:02
nomasp
阅读(200)
推荐(0)
摘要:
练习1.40首先根据公式x^3+ax^2+bx+c写出相应的cubic过程,它的返回值是一个接受参数x的过程:(define (cubic a b c)(lambda (x)(+ (cube x)(* a (square x))(* b x)c)))(newtons-method (cubic ...
阅读全文
posted @ 2015-02-17 20:01
nomasp
阅读(107)
推荐(0)
摘要:
练习1.39没想到最后一道题如此简单,n和d的过程可以如下定义:(define (n i)(if (= i 1)i(- (* i i))))(define (d i)(- (* 2 i) 1))这里我们就不再重复写成块结构了。(define (tan-cf x k)(cont-frac n d ...
阅读全文
posted @ 2015-02-17 20:01
nomasp
阅读(102)
推荐(0)
摘要:
练习1.38我最喜欢做数学上的观察题了,这里也有一个Di,其依次为1,2,1,1,4,1,1,6,1,1,8……我最先看到的是除了一开始的2个之外,每三个数字的规律是前面是两个1,后面是个递增的偶数。于是我们便可轻而易举的写出这个函数了。(define (d i)(if (= (remainde...
阅读全文
posted @ 2015-02-17 20:00
nomasp
阅读(121)
推荐(0)
摘要:
练习1.37根据题目中的意思通过观察得到k项有项连分式的一种表达方式:f=N1/(D1+(N2/(…+Nk/Dk)))这个式子可以不断展开,但如果我们把每一个”+”后面的式子记作T(i)。不对,我们应该将每一个N/D记作T(i),因为这组式起始于N/D,且中止与N/D。计N1/D1为T(1),N...
阅读全文
posted @ 2015-02-17 19:59
nomasp
阅读(108)
推荐(0)
摘要:
练习1.36这道题要求我们根据书上的newline和display来完成一个新版本的fixed-point。根据题目内容我们分为如下步骤:1、写出能够打印出计算中产生的近似值序列的函数。2、将第一步中的函数写入fixed-point中。3、根据题中的映射关系写出对应函数。4、根据下一节的内容写出...
阅读全文
posted @ 2015-02-17 19:59
nomasp
阅读(167)
推荐(0)
摘要:
练习1.35依旧是每一小节中比较简单的第一题,计算黄金分割率的过程如下:(define get-golden-ratio(fixed-point (lambda (x) (+ 1 (/ 1 x))) 1.0))虽然比较简单,但我们还是测试一下:get-golden-ratio;Value: 1....
阅读全文
posted @ 2015-02-17 19:58
nomasp
阅读(104)
推荐(0)
摘要:
练习1.34这道题我一开始不用Edwin的时候觉得是会陷入无限循环之中。后来在Edwin上试了一下才发现会报错,输出如下:(f f);The object 2 is notapplicable.;To continue, call RESTARTwith an option number:;(R...
阅读全文
posted @ 2015-02-07 13:51
nomasp
阅读(105)
推荐(0)
摘要:
sealed关键字如果我们将类标记为sealed,编译器将不会允许我们从这个类型派生。(C#结构总是隐式密封的。因此,我们永远不可以从结构继承结构,从类继承结构或从结构继承类。结构只能用于建模独立的、用户定义的数据类型。如果希望是is-a关系,就必须使用类。)使用base关键字控制基类的创建pr...
阅读全文
posted @ 2015-02-07 13:24
nomasp
阅读(160)
推荐(0)
摘要:
C#文件属性什么是文件属性文件属性可以用来指示项目系统对应文件执行的操作。具体的操作见下文。Visual Basic和Visual C#的文件都具有4个属性:“FileName”、“BuildAcition”、“CustomTool”、”CustomToolNamespace“。 C...
阅读全文
posted @ 2015-02-07 13:22
nomasp
阅读(370)
推荐(0)
摘要:
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,a2 + b2 = c2For example, 32 + 42 = 9 + 16 = 25 = 52.There exists exact...
阅读全文
posted @ 2015-02-07 12:26
nomasp
阅读(120)
推荐(0)
摘要:
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,a2 + b2 = c2For example, 32 + 42 = 9 + 16 = 25 = 52.There exists exact...
阅读全文
posted @ 2015-02-07 12:26
nomasp
阅读(175)
推荐(0)
摘要:
//By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.//What is the 10 001st prime number?static voi...
阅读全文
posted @ 2015-02-07 12:25
nomasp
阅读(128)
推荐(0)
摘要:
//The sum of the squares of the first ten natural numbers is, //12 + 22 + ... + 102 = 385 //The square of the sum of the first ten natural numbers i...
阅读全文
posted @ 2015-02-07 12:24
nomasp
阅读(94)
推荐(0)
摘要:
//2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.//What is the smallest positive number t...
阅读全文
posted @ 2015-02-07 12:24
nomasp
阅读(108)
推荐(0)
摘要:
//A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.//Find the la...
阅读全文
posted @ 2015-02-07 12:23
nomasp
阅读(130)
推荐(0)
摘要:
//The prime factors of 13195 are 5, 7, 13 and 29. //What is the largest prime factor of the number 600851475143 ? static void Main(string[] args) { ...
阅读全文
posted @ 2015-02-07 12:21
nomasp
阅读(104)
推荐(0)
摘要:
//Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be://1, 2...
阅读全文
posted @ 2015-02-07 12:20
nomasp
阅读(117)
推荐(0)
摘要:
//If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.//Find the sum of...
阅读全文
posted @ 2015-02-07 12:19
nomasp
阅读(110)
推荐(0)
摘要:
一、综述本节我们将来探讨关于图像处理方面的诸多技术和应用。在学完了第一个常用的工具包之后,学习这一节将更加轻松。废话不多说,切入正题。二、平滑处理和图像形态学1、滤波器"平滑处理“或者也称为”模糊处理“,英文名为blurring。对于平滑处理,我们先来介绍一个重要的函数,所有的操作都由这个函数来...
阅读全文
posted @ 2015-02-07 12:17
nomasp
阅读(215)
推荐(0)
摘要:
通过HighGUI(high-level graphical user interface)可以实现打开窗口、显示图像、读出和写入图像文件,处理鼠标、光标、键盘事件。而HighGUI主要分成“视频输入/输出”、“图像输入/输出”和“GUI工具”,分别在cacap*、grfmt*和window*源...
阅读全文
posted @ 2015-02-07 12:11
nomasp
阅读(293)
推荐(0)
摘要:
实例一int main(){IplImage* img = cvLoadImage("6085.jpg", 1);IplImage* red = cvCreateImage(cvGetSize(img), img->depth, 1);IplImage* green = cvCreateImag...
阅读全文
posted @ 2015-02-07 12:10
nomasp
阅读(230)
推荐(0)
摘要:
除了读入图片之外,读写视频也足够简单易学,下面来看看如何读写视频吧。播放硬盘中的视频:#include "highgui.h"int main(int argc,char** argv){ cvNamedWindow("Test2",CV_WINDOW_AUTOSIZE); CvCap...
阅读全文
posted @ 2015-02-07 10:55
nomasp
阅读(293)
推荐(0)
摘要:
#include "highgui.h"int main(int argc,char** argv){ IplImage* img=cvLoadImage(argv[1]); cvNamedWindow("Test1",CV_WINDOW_AUTOSIZE); cvShowI...
阅读全文
posted @ 2015-02-07 10:53
nomasp
阅读(118)
推荐(0)
摘要:
练习1.33题目第二行描述,只组合起由给定范围得到的项里的那些满足特定条件的项,因此我们需要在这一版本的accumulate中添加一个need-filter?,这个新的谓词可以用来传递下面就要用到的prime?。(define (filtered-accumulateneed-filter? c...
阅读全文
posted @ 2015-02-07 10:37
nomasp
阅读(125)
推荐(0)
摘要:
练习1.32因为递归比迭代要更容易实现,因此我先考虑的递归。先将sum和product都列出来。(define (sum term a next b)(if(> a b)0(+(term a)(sum term (next a) next b))))(define (product term a...
阅读全文
posted @ 2015-02-07 10:36
nomasp
阅读(77)
推荐(0)
摘要:
练习1.31题目中已经说的很清楚了,product用来返回在给定范围中各点的某个函数值的乘积。我们惊奇的发现这和前面的sum有着很大的相似,无非是将加法换成了乘法:(define (product term a next b)(if(> a b)1(* (term a)(product term...
阅读全文
posted @ 2015-02-07 10:35
nomasp
阅读(153)
推荐(0)
摘要:
练习1.30这道题要求将一个递归的规程改成是迭代的,通过对递归版本的sum的观察得出以下变换形式:a—(next a)other—(+ (term a) other)博主英文不太好实在想不出什么好词语了。变换成迭代通俗点讲就是要将sum中最后一行的加号去掉,因为这个是消耗大量空间的根源。如果我们...
阅读全文
posted @ 2015-02-07 10:34
nomasp
阅读(75)
推荐(0)
摘要:
练习1.29这道题的数学气息比较浓厚。像变量h和函数y在书中已经有了定义,并且n是偶数。另外通过观察我们发现当k等于0或者n时,y的系数为1;当k为偶数时,y的系数为2;当k为奇数时(在函数中直接用else也可以),y的系数为4。根据书中前面的讲解,需要有一个term作用在a上,还要有一个nex...
阅读全文
posted @ 2015-02-07 10:33
nomasp
阅读(102)
推荐(0)
摘要:
练习1.28这道题主要分为三个部分:1、非平凡平方根,并添加到expmod函数中2、类似于fermat-test的过程3、通过已知的素数和非素数来检验下面我们首先来写出能够在遇到非平凡平方根的时候报错的函数,在这个函数中:当x不等于1,x不等于(n-1),并且x的平方对n取余等于1,这三个条件都...
阅读全文
posted @ 2015-02-07 10:31
nomasp
阅读(191)
推荐(0)