博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Borrowers
阅读量:6487 次
发布时间:2019-06-24

本文共 3613 字,大约阅读时间需要 12 分钟。

Description

I mean your 
borrowers of books - those mutilators of collections, spoilers of the symmetry of shelves, and creators of odd volumes.

- (Charles Lamb, Essays of Elia (1823) `The Two Races of Men')

Like Mr. Lamb, librarians have their problems with borrowers too. People don't put books back where they should. Instead, returned books are kept at the main desk until a librarian is free to replace them in the right places on the shelves. Even for librarians, putting the right book in the right place can be very time-consuming. But since many libraries are now computerized, you can write a program to help.

 

When a borrower takes out or returns a book, the computer keeps a record of the title. Periodically, the librarians will ask your program for a list of books that have been returned so the books can be returned to their correct places on the shelves. Before they are returned to the shelves, the returned books are sorted by author and then title using the ASCII collating sequence. Your program should output the list of returned books in the same order as they should appear on the shelves. For each book, your program should tell the librarian which book (including those previously shelved) is already on the shelf before which the returned book should go.

 

First, the stock of the library will be listed, one book per line, in no particular order. Initially, they are all on the shelves. No two books have the same title. The format of each line will be:

``titlebyauthor

The end of the stock listing will be marked by a line containing only the word:

END

Following the stock list will be a series of records of books borrowed and returned, and requests from librarians for assistance in restocking the shelves. Each record will appear on a single line, in one of the following formats:

BORROW ``title"

RETURN ``title"

SHELVE

The list will be terminated by a line containing only the word:

END

 

Each time the SHELVE command appears, your program should output a series of instructions for the librarian, one per line, in the format:

Put `` tex2html_wrap_inline61 " after `` tex2html_wrap_inline63 "

or, for the special case of the book being the first in the collection:

Put ``titlefirst

After the set of instructions for each SHELVE, output a line containing only the word:

END

 

 

Assumptions & Limitations:

1. A title is at most 80 characters long.

2. An author is at most 80 characters long.

3. A title will not contain the double quote (") character.

 

 

"The Canterbury Tales" by Chaucer, G."Algorithms" by Sedgewick, R."The C Programming Language" by Kernighan, B. and Ritchie, D.ENDBORROW "Algorithms"BORROW "The C Programming Language"RETURN "Algorithms"RETURN "The C Programming Language"SHELVEEND

 

 

Put "The C Programming Language" after "The Canterbury Tales"Put "Algorithms" after "The C Programming Language"END 这道题完全是借鉴别人博客上的,不过当时没有理解深刻,所以犯了几个小错误 WA代码:
#include"iostream"#include"cstring"#include"sstream" #include"set" #include"map" using namespace std; struct node{ string name,author; friend bool operator <(node a,node b){ if(a.author==b.author) return a.name
p; //存放书架上原有书籍 set
q; //存放借阅和归还信息 map
mp; string fun(string c) { for(int i=0;i
>cc) { if(f++) rev+=' '; rev+=cc; } return rev; } void deal(string temp) //存好书架上的信息 { for(int i=0;i
>s) { if(s=="by") { flag=1; } if(flag!=1) { if(f++) e.name+=' '; e.name+=s; } if(flag==1) { if(f++) e.author+=' '; e.author+=s; } } p.insert(e); mp[e.name]=e.author; } int main() { string

转载于:https://www.cnblogs.com/zsyacm666666/p/4659843.html

你可能感兴趣的文章
Rhel6-heartbeat+lvs配置文档
查看>>
0317复利计算的回顾与总结
查看>>
函数对象
查看>>
最全最新个税计算公式---今天你税了吗?
查看>>
linux shell 正则表达式(BREs,EREs,PREs)差异比较(转,当作资料查)
查看>>
二分法求平方根(Python实现)
查看>>
使用startActivityForResult方法(转)
查看>>
so在genymotation中错误问题
查看>>
Visual Studio 原生开发的10个调试技巧(二)
查看>>
Windows内核再次出现0Day漏洞 影响win2000到win10所有版本 反病毒软件恐成瞎子
查看>>
H3C品牌刀片系统强势首发
查看>>
【CSS系列】图像映射
查看>>
First blood
查看>>
删除恢复Hadoop集群中的DataNode
查看>>
Silverlight 2动态创建矩形对象(附完整源代码)
查看>>
从京东技术演进看互联网企业的成长历程
查看>>
MFC ado+mysql+odbc技术分享
查看>>
js中让字符串中特定字符红色显示
查看>>
redhat Nginx 安装
查看>>
oracle 配置监听
查看>>