摘要: 练习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) 推荐(0)
摘要: sealed关键字如果我们将类标记为sealed,编译器将不会允许我们从这个类型派生。(C#结构总是隐式密封的。因此,我们永远不可以从结构继承结构,从类继承结构或从结构继承类。结构只能用于建模独立的、用户定义的数据类型。如果希望是is-a关系,就必须使用类。)使用base关键字控制基类的创建pr... 阅读全文
posted @ 2015-02-07 13:24 nomasp 阅读(160) 评论(0) 推荐(0)
摘要: C#文件属性什么是文件属性文件属性可以用来指示项目系统对应文件执行的操作。具体的操作见下文。Visual Basic和Visual C#的文件都具有4个属性:“FileName”、“BuildAcition”、“CustomTool”、”CustomToolNamespace“。 C... 阅读全文
posted @ 2015-02-07 13:22 nomasp 阅读(370) 评论(0) 推荐(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) 推荐(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) 推荐(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) 推荐(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) 推荐(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) 推荐(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) 推荐(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) 推荐(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) 推荐(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) 推荐(0)
摘要: 一、综述本节我们将来探讨关于图像处理方面的诸多技术和应用。在学完了第一个常用的工具包之后,学习这一节将更加轻松。废话不多说,切入正题。二、平滑处理和图像形态学1、滤波器"平滑处理“或者也称为”模糊处理“,英文名为blurring。对于平滑处理,我们先来介绍一个重要的函数,所有的操作都由这个函数来... 阅读全文
posted @ 2015-02-07 12:17 nomasp 阅读(215) 评论(0) 推荐(0)
摘要: 通过HighGUI(high-level graphical user interface)可以实现打开窗口、显示图像、读出和写入图像文件,处理鼠标、光标、键盘事件。而HighGUI主要分成“视频输入/输出”、“图像输入/输出”和“GUI工具”,分别在cacap*、grfmt*和window*源... 阅读全文
posted @ 2015-02-07 12:11 nomasp 阅读(293) 评论(0) 推荐(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) 推荐(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) 推荐(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) 推荐(0)
摘要: 练习1.33题目第二行描述,只组合起由给定范围得到的项里的那些满足特定条件的项,因此我们需要在这一版本的accumulate中添加一个need-filter?,这个新的谓词可以用来传递下面就要用到的prime?。(define (filtered-accumulateneed-filter? c... 阅读全文
posted @ 2015-02-07 10:37 nomasp 阅读(125) 评论(0) 推荐(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) 推荐(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) 推荐(0)
摘要: 练习1.30这道题要求将一个递归的规程改成是迭代的,通过对递归版本的sum的观察得出以下变换形式:a—(next a)other—(+ (term a) other)博主英文不太好实在想不出什么好词语了。变换成迭代通俗点讲就是要将sum中最后一行的加号去掉,因为这个是消耗大量空间的根源。如果我们... 阅读全文
posted @ 2015-02-07 10:34 nomasp 阅读(75) 评论(0) 推荐(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) 推荐(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) 推荐(0)
摘要: 练习1.27这道题的场景是在注释47中,博主更关心的问题是:(第三行)撞上能欺骗费马检查的值的概率有多少,居然会比什么宇宙射线造成计算机出差。后者个人感觉是永远不会发生的,前者倒是还有可能发生。希望把前者的概率算出来的童鞋将过程列出来啦!言归正传,题目的意思就是要去验算注释47中的那几个Carm... 阅读全文
posted @ 2015-02-07 10:30 nomasp 阅读(98) 评论(0) 推荐(0)
摘要: 练习1.26这本书的练习好像很多都和某个人有关,不愧是一本经典著作,通过MIT大量的修修补补。下面我们进入正题吧,Louis的问题就在于计算了2次(expmod base (/ exp 2) m),如果是用的square,则只会计算一次。更何况在这多余的一次里,又是一个漫长的迭代。Lisp最吸引... 阅读全文
posted @ 2015-02-07 10:30 nomasp 阅读(128) 评论(0) 推荐(0)
摘要: 练习1.25这道题由Alyssa的一个另一版本的expmod来引出,这个expmod的功能和之前的一样的。但是之前版本的expmod每次都有一个remainder来讲乘幂控制在一个不大的范围内,这样通过不断的迭代,将很大的数字分解开来得以加快计算速度。而题目中这一版本的expmod则只通过了一次... 阅读全文
posted @ 2015-02-07 10:29 nomasp 阅读(128) 评论(0) 推荐(0)
摘要: 练习1.24我们先将书中已给出的代码写入Edwin中。(define (fermat-test n)(define (try-it a)(= (expmod a n n) a))(try-it (+ 1 (random (- n 1)))))(define (fast-prime? n time... 阅读全文
posted @ 2015-02-07 10:28 nomasp 阅读(119) 评论(0) 推荐(0)
摘要: 练习1.23首先我们按照题目要求来写出相应的next函数,然后再修改find-divisor函数。(define (next x)(if(= x 2)3(+ n 2)))(define(find-divisor ntest-divisor)(cond((> (square test-diviso... 阅读全文
posted @ 2015-02-07 10:28 nomasp 阅读(84) 评论(0) 推荐(0)
摘要: 练习1.22这道题中需要判断素数的部分书中都已经列出来了,但要求是要找出多个素数,因此我们要有一个能够不断求素数的函数。在C等语言中我们可以通过一个for循环来轻易地求出来,在Scheme中我们完全可以用迭代来实现这一功能。另外因为是要的素数,因此完全不用考虑偶数了。于是我们先来写一个不断求奇数... 阅读全文
posted @ 2015-02-07 10:26 nomasp 阅读(117) 评论(0) 推荐(0)
摘要: 练习1.21这道题几乎没有难度,除非在把书中函数写入到Edwin中时输入错误。(smallest-divisor 199);Value: 199(smallest-divisor 1999);Value: 1999(smallest-divisor 19999);Value: 19999 ... 阅读全文
posted @ 2015-02-07 10:26 nomasp 阅读(89) 评论(0) 推荐(0)