0%

在伪代码中,每一条指令占一行(else if 例外),指令后不跟任何符号,缩进表示程序中的分支结构
定义变量的语句不用写出来,但必须在注释中给出

某些指令或子任务可以用文字来叙述,例如,”设x是A中的最大项”,这里A是一个数组;或者”将x插入L中”,这里L是一个链表
算术表达式可以使用通常的算术运算符(+,-,*,/,以及表示幂的^)。逻辑表达式可以使用关系运算符=,≠,<,>,≤和≥,以及逻辑运算符与(and),或(or),非(not)。

赋值语句:a←b 。
这里a是变量、数组项,b是算术表达式、逻辑表达式或指针表达式。
变量交换:a<->b
goto语句导致转向具有指定标号的语句。

条件语句:

1
2
3
4
5
6
if i=10
then xxxx //if 后面必定跟上then,else后面不用跟then
elseif i=9 //elseif 要连在一起写,else 和 then 要对齐
then xxxx
yyyy
else xxxx//else 跟在elseif 的 then 对齐

循环:while和for

1
2
3
4
5
6
7
8
9
10
11
12
while time<10
do xxxxx //while后面必定要紧跟缩进的do
xxxxx
end

for var init to limit by incr do
s
end

for i←0 to 10 //for、while、if 后面的条件语句都不用加括号
do ... //for后面必定要紧跟缩进的do
...

exit语句可以在通常的结束条件满足之前,被用来结束while循环或者for循环的执行。exit导致转向到紧接在包含exit的(最内层)while或者for循环后面的一个语句。

return用来指出一个算法执行的终点;如果算法在最后一条指令之后结束,它通常是被省略的;它被用得最多的场合是检测到不合需要的条件时。return的后面可以紧接被括在引号的信息。

算法中的注释被括在/ /之中。诸如read和output之类的各种输入或者输出也在需要时被用到。

原文:https://blog.csdn.net/u010126059/article/details/51077514

DDL - Data Definition Language

CREATE (1) Table - define table name, attributes, types

​ (2) View - define user view of data

​ (3) Index - create index on nominated attributes

DROP (1) Table - delete table, attributes and values

​ (2) View - delete user view(s)

​ (3) Index - delete index, indexes

​ Some DBMS have an ALTER command to vary attribute characteristics.

键的声明

声明含单个属性的键:在属性后面加PRIMARY KEY 或 UNIQUE

指明为UNIQUE的属性,允许有空值,但不允许多个空值(除了SQL SERVER 以外的大型数据库都是允许 UNIQUE约束有多个空值的。);指明为PRIMARY KEY 的属性不允许有空值。

声明含多个属性的键:单独作为表的一个元素。

PRIMARY KEY 仅有一个; UNIQUE 可以有多个。

外键

关键字:REFERENCES

含单个属性的外键:在属性后面加 REFERENCES \ (\)

含多个属性的外键:单独作为表的一个元素。FOREIGN KEY ( \ ) REFERENCES \ ( \ )

被参照的属性必须是其他表的PRIMARY KEY 或 UNIQUE

更新操作

例:

1
2
3
4
5
6
7
8
CREATE TABLE Beers (
name CHAR(20) PRIMARY KEY,
manf CHAR(20) );
CREATE TABLE Sells (
bar CHAR(20),
beer CHAR(20),
price REAL,
FOREIGN KEY(beer) REFERENCES Beers(name));

对Beers进行修改,会有三种情况:Default (Reject),Cascade,Set NULL

其他

1
2
3
4
5
6
7
8
9
10
CREATE TABLE Sells (
bar CHAR(20),
beer VARCHAR(20) DEFAULT 'HouseBeer',
price REAL NOT NULL,
PRIMARY KEY (bar,beer)
);

ALTER TABLE Bars ADD phone CHAR(16) DEFAULT 'unlisted';
ALTER TABLE Bars DROP COLUMN license;
ALTER TABLE Sells ADD CHECK(…);

DML - Data Manipulation Language

SQL Queries

重命名 SELECT name AS beer (“AS” could be omitted)

select语句中可加表达式:SELECT bar, beer, price*120 AS priceInYen

在每一行增加一个固定的值:SELECT drinker, ‘likes Bud’ AS whoLikesBud

当字符串中有单引号时,改成双引号:WHERE bar = ‘Joe’’s Bar’ AND beer = ‘Bud’;

=,<>,<,>,<=,>=

AND, OR, NOT

格式:Attribute LIKE pattern (或NOT LIKE)

% stands for any string

_ stands for any one character

空值(未知或不可用)

比较的三种结果: TRUE, FALSE, UNKNOWN,任何值与NULL比较,结果为UNKNOWN,where筛选语句只留下结果为TRUE的

•TRUE = 1, FALSE = 0, and UNKNOWN = ½.

•AND = MIN; OR = MAX, NOT(x) = 1-x

输出排序:

–ORDER BY \

–ASC (升序,默认值),DESC (降序)

Multi-relation Queries

别名:FROM Beers b1, Beers b2

WHERE b1.manf = b2.manf AND b1.name < b2.name;

子查询

in / not in 会去重

例:已知关系模式 R(a,b)和 S(b,c):

Q1: SELECT a FROM R,S WHERE R.b=S.b;

Q2: SELECT a FROM R WHERE b IN (SELECT b FROM S);

Q1的结果总是包含Q2的结果

“EXISTS(relation)” is true if the relation is nonempty.

例:

Find the beers that are the unique beer by their manufacturer.

1
2
3
4
SELECT  name
FROM Beers b1
WHERE NOT EXISTS (SELECT * FROM Beers
WHERE manf = b1.manf AND name <> b1.name);

x = ANY( \ ) is true if and only if x equals at least one tuple in the relation.

–That is, x is a member of the relation (x IN \)

等号可以被替换:x > ANY(\ ) means x is larger than at least one tuple in the relation.

–Note tuples must have one component only.

x <> ALL( \ ) is true if and only if for every tuple t in the relation, x is not equal to t.

–That is, x is not a member of the relation (x NOT IN \).

<>可以被替换

•x >= ALL( \ ) means there is no tuple larger than x in the relation.

–Note tuples must have one component only.

这里注意:之前找最大值的时候喜欢用排序后 select top 1 的方法,但现在看来,top 1只能选出第一行数据,却不能选出并列的第一名的数据,练习中需要改正,或者尝试使用max(),min()

例:选择出预算最小的项目

1
2
3
select projectname
from project
where budget<=ALL (select budget from project)
易错点

Q1: SELECT a FROM R WHERE b>= ANY (SELECT d FROM S WHERE c>10);

Q2: SELECT a FROM R WHERE b>= ALL (SELECT d FROM S WHERE c>10);

当子查询为空时,Q1和Q2结果不一样,上面为空,下面为所有!

—–

Union, Intersection, Difference 对子查询进行集合操作,要求子查询的结果表具有相同的属性和属性类型,查询用括号括起来。

关于去重:包和集合,select-from-where 结果是 bag,union,intersection, or difference 是 set,集合在select之后会自动加 distinct(去重)

聚集操作:sum, avg, min, max, count, count(*)

空值在任何聚集操作中都被忽视,除了count(*)

所以当group by 的属性为空时,该元组被过滤

GROUP BY (attribute list); –Select-from-where-group by

例:Find, for each drinker, the average price of Bud at the bars they frequent.

1
2
3
SELECT 	drinker, AVG(price) FROM Frequents, Sells
WHERE beer = 'Bud' AND Frequents.bar = Sells.bar
GROUP BY drinker;


不是每个在frequent中出现的drinker,都会在结果关系中出现。有可能他常去的酒吧都不售卖bud啤酒,经过选择运算之后,就被过滤掉了。

若select中有聚集运算,那么就不能出现group by中没有的属性。

HAVING clauses are selections on groups.Having中不以聚集形式出现的属性只能是group by的属性。

我平时对于需要在分组后筛选的属性,习惯于把他们加在group by后面,应该学习一下下面这个例子的写法:

Find the average price of those beers that are either served in at least 3 bars or manufactured by Busch.

1
2
3
SELECT 	beer, AVG(price) FROM 	Sells GROUP BY 	beer
HAVING COUNT(*) >= 3 OR beer IN (SELECT name FROM Beers
WHERE manf = 'Busch');

如果写成:

1
2
SELECT beer, AVG(price) FROM Sells GROUP BY beer,manf
HAVING COUNT(*) >= 3 OR manf = 'Busch';

如果啤酒和厂商是多对多,count(*)会数少了,数据条数也会变多。


Q1: SELECT DISTINCT a FROM R WHERE b>10;

Q2: SELECT a FROM R WHERE b>10 GROUP BY a;

Q1和Q2产生相同的结果。

R(A,B,C):

Q1: SELECT DISTINCT * FROM R;

Q2: SELECT * FROM R GROUP BY A,B,C;

Q1和Q2产生相同的结果。

More SQL

Modification 增删改

•INSERT INTO relation VALUES (list of values);

•INSERT INTO relation (subquery);

•DELETE FROM relation WHERE condition;

•UPDATE relation SET assignments WHERE condition;

例:

•Create a table of all Sally’s potential buddies, i.e., the people who frequent bars that Sally also frequents.

1
2
3
4
5
6
7
CREATE TABLE PotBuddies(name char(30));
INSERT INTO PotBuddies
(SELECT DISTINCT d2.drinker
FROM Frequents d1, Frequents d2
WHERE d1.drinker = 'Sally' AND
d2.drinker <> 'Sally' AND
d1.bar = d2.bar);

基于属性的检查 check

只在插入和更新时起作用,在被参照表删除或更新时,不起作用,区别于外键约束。删除元组时不检查,可能违反约束,区别于assertion。

断言 ASSERTION

总是为真。例:

No bar may charge an avg. of more than $5 for beer.

1
2
3
4
5
6
CREATE ASSERTION NoRipoffBars
CHECK (NOT EXISTS(
SELECT bar
FROM Sells
GROUP BY bar
HAVING 5.0 < AVG(price)));

There cannot be more bars than drinkers.

1
2
3
CREATE ASSERTION FewBar
CHECK( (SELECT COUNT(*) FROM Bars) <=
(SELECT COUNT(*) FROM Drinkers));

Trigger

•Whenever a new tuple is inserted into Sells:

–If the beer mentioned is not in Beers, then insert it (with a null manufacturer).

1
2
3
4
5
6
7
CREATE TRIGGER BeerTrig
AFTER INSERT ON Sells -- INSERT can be DELETE or UPDATE OF <attr>.
FOR EACH ROW --FOR EACH ROW can be omitted
WHEN(:new.beer NOT IN (SELECT name FROM Beers))
BEGIN
INSERT INTO Beers(name) VALUES(:new.beer);
END;

存储过程

一组为了完成特定功能的Transact-SQL语句集合。

域完整性约束

sql sever的三种机制:缺省值、规则、用户定义的数据类型

局部变量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
DECLARE @avg_budget int,@extra_budget int
SET @extra_budget=15000
SELECT @avg_budget=AVG(budget) FROM project
IF (SELECT budget
FROM project
WHERE projectno='p1')<@avg_budget
BEGIN
UPDATE project
SET budget=budget+@extra_budget
WHERE projectno='p1'
PRINT 'Budget for p1 increased by 15000'
END
ELSE
PRINT 'Budget for p1 unchanged'

视图

1
2
3
4
CREATE VIEW v_count(projectno,countproject)
AS SELECT projectno,COUNT(*)
FROM workson
GROUP BY projectno;

执行CREATE VIEW语句只是把视图的定义存入数据字典,并不执行SELECT语句

SQL Authorization

授权

1
2
3
4
5
6
7
8
9
10
11
GRANT <list of privileges>
ON <relation or other object>
TO <list of authorization ID’s>;

-- 如果想要接受者可以传递特权,使用:
WITH GRANT OPTION

GRANT SELECT, UPDATE(price) ON Sells TO sally;
-- Sally has the right to issue any query on Sells and can update the price component only
GRANT UPDATE ON Sells TO sally WITH GRANT OPTION;
-- Sally can not only update any attribute of Sells, but can grant to others the privilege UPDATE ON Sells.

收权

1
2
3
4
REVOKE <list of privileges>
ON <relation or other object>
FROM <list of authorization ID’s>;
--这些用户可能还是可以使用该特权,因为他们可能从其他地方获得授权

两种方式:RESTRICT, CASCADE

授权图

节点

user/privilege/option/isOwner

对于特权,不同属性上的操作是不同的节点,可传递和不可传递特权的用户是不同的节点;节点中AP表示A用户有P特权。P*表示P with grant option。P 表示P的源头,AP 表示A is the owner of the object on which P is a privilege.

X->Y,X用来授权Y

•When A grants P to B, we draw an edge from AP * or AP ** to BP.

–Or to BP * if the grant is with grant option.

•If A grants a subprivilege Q of P (say UPDATE(a) on R when P is UPDATE ON R) then the edge goes to BQ or BQ *, instead.

•Fundamental rule: user C has privilege Q as long as there is a path from XQ (the origin of privilege Q ) to CQ, CQ *, or CQ.

–Remember that XQ could be CQ.

•If A revokes P from B with the CASCADE option, delete the edge from AP to BP.

If A uses RESTRICT, and there is an edge from BP to anywhere, then reject the revocation and make no change to the graph.

•Having revised the edges, we must check that each node has a path from some ** node, representing ownership.

•Any node with no such path represents a revoked privilege and is deleted from the diagram.

例题

Initially, user A is the owner of relation R, and no other user holds privileges on R. The following are executed:

by A: GRANT UPDATE ON R TO B

by A: GRANT UPDATE(a) ON R TO C WITH GRANT OPTION

by C: GRANT UPDATE(a) ON R TO B WITH GRANT OPTION

by A: REVOKE UPDATE(a) ON R FROM C CASCADE

Which of the following best describes the status of B’s privileges on R?

(a) B can update any attribute of R except a but cannot grant that privilege.

(b) B has no privileges on R and cannot grant any.

(c) B can update any attribute of R except a, but can grant others the privilege to update R:a .

(d) B can perform any update on R but cannot grant that privilege.

Consider a database with relation R and users Alice, Bob, Carol, and Dave. Alice owns relation R. The following sequence of operations takes place:

Alice: GRANT SELECT ON R TO Bob WITH GRANT OPTION

Alice: GRANT SELECT ON R TO Carol WITH GRANT OPTION

Carol: GRANT SELECT ON R TO Bob WITH GRANT OPTION

Bob: GRANT SELECT ON R TO Dave WITH GRANT OPTION

Carol: GRANT SELECT ON R TO Dave

Dave: GRANT SELECT ON R TO Carol WITH GRANT OPTION

Alice: REVOKE SELECT ON R FROM Bob CASCADE

After these statements are executed, which of the following statements is true?

(a) Dave has the SELECT ON R privilege, but without the grant option.

(b) Dave has the SELECT ON R privilege with the grant option.

(c) Dave does not have the SELECT ON R privilege.

(d) Dave has the grant option for the SELECT ON R privilege, but does not have the privilege itself.

Respect others and your will be respected

写作框架

开头段:开门见山,引出话题

中间段:举例论证重要性、如何做、结果和意义

结尾段:总结、倡导

参考范文

It is a truth universally acknowledged that mutual respect plays a key role in our daily life. Jst as an old saying goes, “Respect others and you will be respected”. Obviously, this proverb teaches us that being respected by others is derived from respecting others.

Why does mutual respect play an important part in our society? Reasons can be listed as follows. First and foremost, all men are created equal which was first written in the U.S. Declaration of Independence. In other words, being respected is the basic right of human being. Moreover, to respect others means understanding others’ situation and respecting others; rights. For me, I have never interrupted others when they are talking or doing their own work. I always keep in mind that without respect, it is hard for me to gain friendship and trust.

In conclusion, respecting others matters a lot in our daily life, which also shows one’s good parenting and quality. The more you respect others, the more you will be respected. Only in this way can we expect our society more harmonious.


title: Words_on_textbook4
tags: CET6—

Unit1

devasting 毁灭性的 bleak 寒冷的,凄凉的
campaign 战役,运动 decisive 决定性的,果断的
retreat 退却 bog (使)陷入泥潭,阻碍 be/get bogged down
take a gramble = take a risk 冒险 press on/ahead 继续前行
bide one’s time 等待时机 cannon 大炮
tattered 衣衫褴褛的 exile 流放,流亡
thrust 推进,刺,戳 catch sb. off guard 趁某人不备
scorch 烧光,烤焦 render 使成为
casualty 伤亡人员 siege 围困
bring to a halt 使停止 counterattack 反攻
turn the tide against 彻底改变形式 unspeakable 糟糕的,不可言状的
reckon with = take into consideration severity 严重性
take its/a roll 造成伤亡 stand/get/be in the way 当道,妨碍

Unit2

lucrative 生利的,赚钱的 fatality 死亡
be crucial to = be fatal for eliminate 消除,消灭
alcohol 酒精 in the air 在空中,悬而未决
on the air 正在直播 be alert to 对…警觉
radar 雷达 prototype 原型
monotonous 单调的 grossly 十足地,严重地
hazard 危险 in hazard 在危险中
at all hazards 在任何情况下 by hazard 偶然
be on the hazard 在危险中 erratic 不规则的,古怪的
vibrate 使振动,摇摆 correlate… with… 使与…相互关联
steer 驾驶,掌舵 poise 使做好准备
be poised to do 做好准备 transmitter 发射机,发报机
obstruct = be/get in the way of sb./sth. = block automate 使自动化
magnetic force 磁力 boon 利益,好处
a bunch of grapes 一串葡萄 in the case of = as far as … is concerned 至于,就……来说

Unit3

applicant applicantion apply for 申请
apply to 适用于 grill 盘问,烧烤
beforehand 事先 follow up 采取进一步行动
see sb. through 使维持,满足某人需求 press conference 记者招待会
in sb’s hands 为某人所拥有 prospective 可能成为的,预期的
as I see it = in my opinion see sb. off 为某人送行
see to sth/sb. 照顾,处理 athlete 运动员
see sth. out 持续某事结束 athletic 活跃的,健壮的
athletics 体育活动 do one’s homework 事先做好准备
go about 从事,处理 make endeavor to 尽可能做某事
go against 违背,对…不利 go ahead 开始,前进
incidentally 顺便提起地,附带地 chuckle 咯咯地笑
be adequate to 胜任 be adequate for 适合
take a crack at 尝试 settle a difference 消除分歧
downright 完全,彻底 filthy 肮脏的
impenetrable 穿不透的 partition 隔墙,隔板
courteously 彬彬有礼地 blurt 未加思索地冲口说出
in the neighborhood of = about

Unit4

asset 财产,资源,优势 fervent 热情的,真挚的
trek 徒步旅行 the Alps 阿尔卑斯山
academic 大学教师,学者 earnest 诚挚的,认真的
considerable 相当多/大的 entitle = give a title to
residue 剩余物 facilitate 使容易,使便利
at odds with 与…冲突,不一致 be committed to 承诺,忠于
endorse: give support or approval to outlook 观点,看法
forefront 最前线,最前面 landmark 有重要意义的
projection 预测 overtake 赶上,超过
pendulum 钟摆 ambivalent 怀有矛盾心情的,暧昧的
patriotic 爱国的 equity 股本,权益
let alone 更不用说 aspire 渴望得到
strike a balance 求得平衡 persuasive writing 议论文

Unit5

deceptive 靠不住的、容易使人上当的 vanity 虚荣、自负
definite 明确的、不含糊的 all of a piece 浑然一体的
accordance 一致,符合 in accordance with= in agreement or harmony with
kindliness 体贴,和善 cocktail 鸡尾酒
something of = to some degree instinct 本能,直觉
lounge 休息室,休息厅 remittance 汇款
oddly enough 说来奇怪 namesake 同名的人
uncanny 不可思议的 chap 家伙,小伙子
with (a) bad/good grace 勉强地/欣然地 stroke-stroked-stroked 击球(动作);轻抚(动物的毛皮);
vein 静脉,血管 transparent 透明的
broke 一文不名的,破了产的 go broke 破产
hitherto 迄今,到目前为止 trim 击败,修剪
pawn 典当,抵押 down and out 穷困潦倒
be/go (all) to pieces 崩溃,垮掉 insane 荒唐的
glimmering 模糊的感觉 drive at 意指,要说
beacon 灯塔,信号灯 creek 小溪
aback 猝不及防地 be taken aback 吃一惊
funk (因恐惧)避开 constitution 体质,体格
dissipation 放荡,玩乐 candid 真诚坦率的

再再再复习一遍文件流,不要再忘了好不好……

ofstream 该数据类型表示输出文件流,用于创建文件并向文件写入信息。
ifstream 该数据类型表示输入文件流,用于从文件读取信息。
fstream 该数据类型通常表示文件流,且同时具有 ofstream 和 ifstream 两种功能,这意味着它可以创建文件,向文件写入信息,从文件读取信息。

源代码文件中包含头文件 \ 和 \

打开文件

在从文件读取信息或者向文件写入信息之前,必须先打开文件。open() 成员函数的第一参数指定要打开的文件的名称和位置,第二个参数定义文件被打开的模式。

模式标志 描述
ios::app 追加模式。所有写入都追加到文件末尾。
ios::ate 文件打开后定位到文件末尾。
ios::in 打开文件用于读取。
ios::out 打开文件用于写入。
ios::trunc 如果该文件已经存在,其内容将在打开文件之前被截断,即把文件长度设为 0。

关闭文件

在程序终止前关闭所有打开的文件,close() 函数。

  • 查询字段值是Null的记录

    判断某个值是否为NULL时,应该用is NULL ,而不是is null

1
select * from tableA where xxx is null
  • 分组统计,数据为空时显示0

(有where条件时,被where条件过滤的数据不显示了)

利用表的关联查询

1
2
3
4
select k.catid,count(t.catid) from 
(select catid from Category) k left join
(select catid from Project left outer join Workson on Project.proid=Workson.proid where empid='10102')t
on k.catid=t.catid group by k.catid
从参考答案上学到另外一种方法:

将 where 换成left outer join… on …. and,用and代替where,在连接的时候过滤,该项会被设为空值,不会在一开始过滤掉需要的空值。另外要注意left outer join 的两张表的顺序

  • 查找选修了全部课程的学生学号

等价于找学生学号,对于这个学号,他所选的课程集合为B,不存在课程集合A,使得A不在B中—使用两个not exist 。但是我又想到,也可以去数这个学生选的课程数,这个课程数等于总的课程数。

1
2
3
4
5
6
7
select 学号 from student
where not exists
(select * from course
where not exists
(select * from takes
where takes.课号=course.课号
and takes.学号=student.学号))

SQL SELECT语句完整的执行顺序:

1、FROM子句组装来自不同数据源的数据; 2、WHERE子句基于指定的条件对记录进行筛选; 3、GROUP BY子句将数据划分为多个分组; 4、使用聚集函数进行计算; 5、使用HAVING子句筛选分组; 6、计算所有表达式; 7、使用ORDER BY对结果进行排序。

将bak文件在SQL SERVER中还原时遇到了两个错误:

还原数据库“XXX”时失败。System.Data.SqlClient.SqlError: 无法执行 BACKUP LOG,因为当前没有数据库备份。

解决方法: 左上角“选项”,去掉“结尾日志备份”的选项

备份集中的数据库备份与现有的数据库不同

解决方法: 左上角“选项”,勾选“覆盖现有数据库”

Whether to Attend College at Home or Abroad?

Currently, with studying abroad gains mounting popularity among people, there is a heated debate about whether to attend college at home or abroad. Opinions on this topic vary from person to person. Some see more benefits in studying at home while others claim that studying abroad is a more ideal choice as it’s more challenging.

Personally, I am a strong favorer of the latter view. Listed below are the reasons for my advice. First of all, attending college abroad provides an opportunity to broaden one’s experience and mind. You can acquire cross-cultural experiences and gain new perspectives on your chosen field of study. In addition, studying abroad helps you to polish your social skills; you can make friends with different people with different background. Thirdly, overseas studying is conductive to the formation of an independent, autonomous and tenacious personality, which will ultimately benefit the achievement of our life goals.

Just as an old saying goes: ”It is better to travel thousand miles than to read ten thousand books.” Then studying abroad can not only enable us to reap in our books, but also in our trips. And this is why attending college abroad is a preferable selection for me.

Notes

mounting [ˈmaʊntɪŋ] adj.上升的;增长的

conductive adj. 导电(或热等)的

Singapore is a conductive environment for studies and learningEnglish. 新加坡是个学习英语和搞研究的好环境。

Understanding China’s history and culture is conductive to know Chinese well. 了解中国的历史和文化有助于了解中国人民。

tenacious [təˈneɪʃəs] adj. 顽强的、坚持的

In spite of his illness, he clung(v.抓紧) tenaciously to his job.尽管有病在身,他仍顽强地坚持工作


明朝统治中国276年,被人们描绘成人类理有序、社会稳定的最伟大的时代期,手工业的发展促进了市场经济和城市化。大量商品,包括酒和丝绸,都在市场销售。同时,还进外国商品,如时钟和烟进京、南京/扬州这样的大商继形成。也是在明代郑和率领的船队會到印度洋进大规模探险航行。还值得一提的是,中国文学的四大经典名著中有三部写于明代。

The Ming Dynasty, which ruled China for 276 years, was depicted as one of the greatest eras characterized by good governance and stable society in human history. During this period, the blossom of handicraft industry accelerated the process of market economy and urbanization. A great deal of commodities, wine and silk included, were available on the market. In the meantime, clocks and tobacco products, among many other foreign goods, were imported. Major commercial canters like Beijing, Nanjing, Yangzhou and Suzhou took shape successively. It was also in the Ming Dynasty that fleets headed by navigator Zheng He had made seven large scale expeditions to the Indian Ocean. What’s also noteworthy is that three of the Four Great Classical Novels of Chinese Literature were written in the Ming Dynasty.

Notes

governance [ˈɡʌvərnəns] n. 统治;管理方法

noteworthy [ˈnoʊtwɜːrði] adj. 值得注意的;显著的

the Four Great Classical Novels of Chinese Literature 四大名著

be depicted as … 被描述为…

be characterized/featured by … 具有…特征

the blossom of handicraft industry 手工业的发展

took shape successively 相继形成

最后做性能分析的时候可以记个时。

分支界定法解决背包问题

首先回顾一下0-1背包,dp[i][j]代表前i个物品花费的cost为j,所得到的最大的value。现在有多个背包了,于是再加一个维度,dp[i][j][k]表示前i个物品放到j个背包里,第j个背包花费的cost为k,所得到的最大的value。


我,没有,看懂,那些文献。

能写多少,写多少。

需要剪枝生成一棵树,然后找高度最高的。你觉得,从下向上生成怎么样呢?行不通,最后一个都不一定在里面啊!只能从上向下?

每个节点,有m个孩子,它处在第j层的第i个孩子,表示当前的T[j]用的是第i条彩带,也就等于它自身,做一个修改:第i个位置长度减去T[j]。每次向下延伸一层,都要更新孩子节点,把小于最小需求的位置置为false,全为false时,就是叶节点了。

然后求最大的深度。


今天我们的任务是——拿下算法导论!

1558593473324

最优答案是在里面的,但是这个“33686019”是个什么鬼东西?!出错就出在这了。难道是溢出???嗯,加了一个上限,就没问题了,虽然我也不知道他是在哪溢出了。

你肿么二重循环的delete又出问题了?!

Directions

Suppose you are asked to give advice on whether to major in science or humanities at college, write an essay to state your opinion.

我发现word有自动纠正单词错误的功能,相邻字母如果写反了会自动调整,比如”msot”会自动变成”most”,但是如果缺一个字母,则只报错不纠错。这种纠正功能可能是在序列比对算法的基础上的改进,有时间可以研究一下。

Whether to Major in Science or Humanities at College?

Nowadays, as the whole society place increasingly considerable value on education, the question of whether to major in science or humanities at college is not only a concern for students, but also a focal point for parents. Some believe that to dig into science is a better choice because it promises us a brighter future; other may hold the opposite view that humanity knowledge is the foundation of humanity quality.

As for me, both arguments are justified. However, I believe that the important thing is not about which subject is better, what matters most is people who will have to make the decision. In other words, we should not lay one-sided emphasis on the advantages of either subject; on the contrary, the students themselves, their interests and preference, pros and cons are supposed to be taken into consideration. For example, if a student is more adept at humanity where his real interests lie, then he should dedicate to the study on humanity.

Whether to major in science or humanity is a critical choice for every student because its result has a profound influence on personal career development and life style. Thus, we should figure out what we really care about so as not to put the cart before the horse.

notes

  1. considerable [kənˈsɪdərəbl] adj. 相当多(或大、重要等)的

    The project wasted a considerable amount of time and money.那项工程耗费了相当多的时间和资金。

  2. focal [ˈfoʊkl] adj. 中心的;很重要的;焦点的;

  3. dig into 挖掘;调查,刻苦钻研

  4. justified [ˈdʒʌstɪfaɪd] adj.(做某事)有正当理由的;事出有因;合乎情理
    v.证明…正确(或正当、有理);对…作出解释;调整使全行排满;使每行排齐

  5. pros and cons 利弊

    Motherhood has both its pros and cons. 当妈妈既有好的一面,也有不好的一面。

  6. adept [əˈdept] adj. 内行的;熟练的;擅长的 n. 专家,能手

    be adept (at/in sth) | (at/in doing sth) = good at doing sth that is quite difficult

  7. put the cart before the horse 本末倒置

    Yet, this is to put the cart before the horse. 不过,这样说是本末倒置。