`
t0uch
  • 浏览: 56796 次
  • 性别: Icon_minigender_1
  • 来自: 柳州
社区版块
存档分类
最新评论
文章列表
这道题需要一些数学知识,题目中已经提示: 引用Show that if we apply such a transformation Tpq twice, the effect is the same as using a single transformation Tp'q' of the same form, and compute p' and q' in terms of p and q 应用两次Tpq相当于一次Tp'q',所以可以通过这样的方式进行推导: Tpq = bq+aq+ap, bp+aq 将a<-bq+aq+ap,b<-bp+aq代入上面对式子中,得 Tp'q'= ...
不太了解题目的意思,仅仅是把上面的算法改成迭代吗? (define (even? n) (= (remainder n 2) 0)) (define (halve n) (if (even? n) (/ n 2) (/ (- n 1) 2))) (define (double n) (+ n n)) (define (fast-multi a b) (fast-multi-iter 0 a b)) (define (fast-multi-iter r a b) (cond ((= a 0) r) ((even? ...
看来书上的注释做出来了,效仿Russian peasant multiplication算法 (define (even? n) (= (remainder n 2) 0)) (define (halve n) (if (even? n) (/ n 2) (/ (- n 1) 2))) (define (double n) (* n 2)) (define (fast-multi a b) (cond ((= a 1) b) ((even? a) (fast-multi (halve a) (double b))) ...
题目很简单,只要设定一个变量来返回结果和做必要的存储就可以了。 (define (fastexpt a b n p) (cond ((= n 0) p) ((= (remainder n 2) 1) (fastexpt (* a b) b (- n 1) (+ p 1))) (else (fastexpt a (* b b) (/ n 2) (+ p 1)))))
很简单,但是用迭代没做出来,有点困难。不知道怎么判断什么时候该结束。 (define (pascal-triangle row col) (if (or (= col 1) (= col row)) 1 (+ (pascal-triangle (- row 1) (- col 1)) (pascal-triangle (- row 1) col))) )
SICP题目不容易,可以很大程度提高编程能力 递归 (define (f n) (if (< n 3) n (+ (f (- n 1)) (* 2 (f (- n 2))) (* 3 (f (- n 3))))) ) 做迭代部分的时候一时没有理解的 a <- a + b, b <- a。 这里也是同样 在下一轮迭代前,参数应该为a <- a + 2 * b + 3 * c,b <- a, c <- b,知道这个道理就不难做了。 (define (f n) (f-iter 2 1 0 n) ) (define ( ...
不想使用leopard上的ruby,所以就自己编译安装了,下面是安装及使用中遇到的几个问题 由于我已经把leopard上的有关ruby的目录删掉了,所以无法运行ruby,当然,编译的前提是要有xcode 这里用的是ruby网站上最新的包ruby 1.8.7 p72 问题1: 下载包,然后按照教程编译: ./configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1 然后make,发现错误: compiling readline gcc -I. -I../.. -I../../. -I../.././ext/re ...
创建超链接 <html> <body> <p> <a href="/index.html"> This text</a> is a link to a page on this Web site. </p> <p> <a href="http://www.microsoft.com/"> This text</a> is a link to a page on the World Wide Web. </p ...
文本格式化 b,strong标签粗体,br换行,big字体变大,em,i斜体,small字体变小,sub向下靠子字符串,sup向上靠子字符串 <html> <body> <b>This text is bold</b> <br> <strong>This text is strong</strong> <br> <big>This text is big</big> <br> <em>This text ...
本人好记忆力极差,记于此以备查询。 HTML 基础标签实例 一个简单的html <html> <body> <p>试试看</p> </body> </html> 简单的段落 <html> <body> <p>This is a paragraph.</p> <p>This is a paragraph.</p> <p>This is a paragraph.</p> <p>This i ...
Rails 2.1快要release了,下面是对Time Zone一篇文章的翻译,觉得有点意思,便拿来翻译翻译,正好可以学习一番。翻译质量很差,希望不要嘲笑。 (链接在此:http://mad.ly/2008/04/09/rails-21-time-zone-support-an-overview/) 图片就不自己搞rails来原创的,直接取之来用,另外我已将图片打包,免得链接失效了就不好办了 具体的API可以查看http://api.rubyonrails.org/ 可惜可爱的ruby 1.9x 稳定版还是遥遥无期 看看rails 2.1的这个新功能吧,Time Zone 什么是Ti ...
textmate中有大量的snippets来提供快捷输入,节省很多时间 快速闭合标签: 1.按住ctrl+shift+<,这样会得到一个快速闭合标签,输入完后直接按tab来输入标签的内容 如: ctrl+shift+<,然后输入html,然后按tab 2.在输入标签名后,在标签名的右边输入ctrl+shift+<,也可以得到一个快速闭合的标签 3.在输入一个完整的开始标签后,可以输入option+command+. 来得到一个闭合的标签. 如:在输入完<html>后,输入option+command+. 来得到一个闭合标签 4.在输入一行文字后,我希望把这 ...
Rails2出来了这么久,WEB开发敏捷之道--应用RAILS进行敏捷WEB开发第二版前半部的代码对于Rails2已经不适用。我也是RoR初学,就来实践实践。 从Depot建立开始 Let's code! 同样,建立Depot工程 rails depot 首先,打开\config\database.yml文件 可以到如下代码 # SQLite version 3.x # gem install sqlite3-ruby (not necessary on OS X Leopard) development: adapter: sqlite3 database: db/ ...
在别处看到的,感觉挺有趣,转一下 rails todo cd todo rake db:create:all(在这之前要把数据库的用户名和密码输入正确) ruby script/generate scaffold Todo title:string body:text done:boolean due:datetime rake db:migrate 开始服务 ruby script/server 打开浏览器输入并访问http://localhost:3000/todos 这是生成的todos_controller.rb class TodosController < Appl ...
闲来无事,改进改进,多说无益,贴代码,看帖要回帖啊各位 #include < iostream >    #include < time.h >       using namespace std;       struct uni    {        int a, b, c, d;    };       uni can[1032];    const unsigned long punk = 1UL << 2;    int sum = 0,  ...
Global site tag (gtag.js) - Google Analytics