摘要: 原文:http://blog.csdn.net/sheismylife/article/details/1694946顺序容器顺序容器将单一类型的元素聚集起来,然后根据位置来存储和访问这些元素。顺序容器的元素排列次序与元素值无关,而是由元素添加到容器里的次序决定。STL中最常用的顺序容器是vector、list、deque。在这里,我不打算介绍如何使用这些容器类的基本函数,这将作为课后作业。我把篇幅放在如何选择使用这三种容器上。vector<>vector被称为动态数组,原始的静态数组一旦越界可能会悄无声息的修改掉不该修改的内存,而vector会立即出错,抛出异常。vector具备 阅读全文
posted @ 2012-06-05 16:51 Leo Forest 阅读(436) 评论(0) 推荐(0) 编辑
摘要: 摘自:http://www.tsnc.edu.cn/tsnc_wgrj/doc/sed.htm删除:d命令$ sed '2d' example-----删除example文件的第二行。$ sed '2,$d' example-----删除example文件的第二行到末尾所有行。$ sed '$d' example-----删除example文件的最后一行。$ sed '/test/'d example-----删除example文件所有包含test的行。替换:s命令$ sed 's/test/mytest/g' e 阅读全文
posted @ 2012-06-03 18:44 Leo Forest 阅读(423) 评论(0) 推荐(0) 编辑
摘要: 习题地址:http://sqlzoo.net/4.htm表结构: msp(name, party, constituency) party(code, name, leader) msp.party = party.code1a.One MSP was kicked out of the Labour party and has no party. Find him.select name from msp where party is null1b.Obtain a list of all parties and leaders.select name,leader f... 阅读全文
posted @ 2012-06-03 15:47 Leo Forest 阅读(600) 评论(0) 推荐(0) 编辑
摘要: 习题地址:http://sqlzoo.net/4a.htm表结构: teacher(id, dept, name, phone, mobile) dept(id, name) teacher.dept = dept.id1a.List the teachers who have NULL for their department.select name from teacher where dept is null1b.Note the INNER JOIN misses the teacher with no department and the department ... 阅读全文
posted @ 2012-06-02 13:10 Leo Forest 阅读(2144) 评论(0) 推荐(0) 编辑
摘要: 习题地址:http://sqlzoo.net/3.htm表结构: movie(id, title, yr,director) actor(id, name) casting(movieid,actorid, ord)1b.Give year of 'Citizen Kane'.select yr from moviewhere title = 'Citizen Kane'1c.List all of the Star Trek movies, include theidtitleandyr. (All of these movies include the wo 阅读全文
posted @ 2012-06-02 11:46 Leo Forest 阅读(2333) 评论(0) 推荐(0) 编辑
摘要: 习题地址:http://sqlzoo.net/3b.htm表结构: ttms(games,color, who,country) country(id, name) ttms.county = county.id1b.Show the who and the color of the medal for the medal winners from 'Sweden'.select who, colorfrom ttms join countryon (ttms.country = country.id)where country.name = 'Sweden'1 阅读全文
posted @ 2012-06-02 00:40 Leo Forest 阅读(466) 评论(0) 推荐(0) 编辑
摘要: 习题地址:http://sqlzoo.net/1a.htm表结构: bbc(name, region, area, population, gdp)1a.List each country name where the population is larger than 'Russia'.select name from bbc where population > (select population from bbc where name = 'Russia')1b.List thenameandregionof countries in the re 阅读全文
posted @ 2012-06-01 23:54 Leo Forest 阅读(748) 评论(0) 推荐(0) 编辑
摘要: 习题地址:http://sqlzoo.net/1b.htm表结构: nobel(yr, subject, winner)1a.Change the query shown so that it displays Nobel prizes for 1950.select *from nobel where yr = 19501b.Show who won the 1962 prize for Literature.select winner from nobel where yr = 1962 and subject = 'Literature'2a.Show the year 阅读全文
posted @ 2012-06-01 21:33 Leo Forest 阅读(805) 评论(0) 推荐(0) 编辑
摘要: 习题地址:http://sqlzoo.net/3a.htm表结构: album(asin, title, artist, price, release, label, rank) track(album, dsk, posn, song)1b.Whichartistrecorded thesong'Exodus'?select album.artist from album join trackon (album.asin = track.album)where track.song = 'Exodus'1c.Show thesongfor eachtracko 阅读全文
posted @ 2012-06-01 18:22 Leo Forest 阅读(1415) 评论(0) 推荐(0) 编辑
摘要: 习题地址:http://sqlzoo.net/2.htm表结构:bbc(name, region, area, population, gdp)1b.List all the regions - just once each.select distinct region from bbc1c.Give the total GDP of Africaselect sum(GDP) from bbc where region = 'Africa'1d.How many countries have an area of at least 1000000select count(na 阅读全文
posted @ 2012-06-01 16:59 Leo Forest 阅读(569) 评论(0) 推荐(0) 编辑