Simple Library Management System HDU - 1497(图书管理系统)
Problem Description
After AC all the hardest problems in the world , the ACboy 8006 now has nothing to do . One day he goes to an old library to find a part-time job .It is also a big library which has N books and M users.The user's id is from 1 to M , and the book id is from 1 to N . According to the library rules , every user are only allowed to borrow 9 books .But what surprised him is that there is no computer in the library , and everything is just recorded in paper ! How terrible , I must be crazy after working some weeks , he thinks .So he wants to change the situation .
In the other hand , after 8006's fans know it , they all collect money and buy many computers for the library .
Besides the hardware , the library needs a management program . Though it is just a piece of cake for 8006 , the library turns to you , a excellent programer,for help .
What they need is just a simple library management program . It is just a console program , and have only three commands : Borrow the book , Return the book , Query the user .
1.The Borrow command has two parameters : The user id and the book id
The format is : "B ui bi" (1<=ui<=M , 1<=bi<=N)
The program must first check the book bi wether it's in the library . If it is not , just print "The book is not in the library now" in a line .
If it is , then check the user ui .
If the user has borrowed 9 books already, print "You are not allowed to borrow any more" .
Else let the user ui borrow the book , and print "Borrow success".
2.The Return command only has one parameter : The book id
The format is : "R bi" (1<=bi<=N)
The program must first check the book bi whether it's in the library . If it is , just print "The book is already in the library" . Otherwise , you can return the book , and print "Return success".
3.The Query command has one parameter : The user id
The format is : "Q ui" (1<=ui<=M)
If the number of books which the user ui has borrowed is 0 ,just print "Empty" , otherwise print the books' id which he borrows in increasing order in a line.Seperate two books with a blank.
Input
The input file contains a series of test cases . Please process to the end of file . The first line contains two integers M and N ( 1<= M <= 1000 , 1<=N<=100000),the second line contains a integer C means the number of commands(1<=C<=10000). Then it comes C lines . Each line is a command which is described above.You can assum all the books are in the library at the beginning of each cases.
Output
For each command , print the message which described above .
Please output a blank line after each test.
If you still have some questions , see the Sample
Sample Input
5 10
9
R 1
B 1 5
B 1 2
Q 1
Q 2
R 5
Q 1
R 2
Q 1
5 10
9
R 1
B 1 5
B 1 2
Q 1
Q 2
R 5
Q 1
R 2
Q 1
Sample Output
The book is already in the library
Borrow success
Borrow success
2 5
Empty
Return success
2
Return success
Empty The book is already in the library
Borrow success
Borrow success
2 5
Empty
Return success
2
Return success
Empty //Huge input, the function scanf() may work better than cin
Hint
Hint
纯粹的模拟题
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int book[];
struct node
{
int x[];
int y;
} p[];
int main()
{
int n,m,b,u;
char a;
while(cin>>n>>m)
{
memset(book,,sizeof(book));
for(int i=; i<=n; i++)
p[i].y=;
int t;
cin>>t;
while(t--)
{
cin>>a;
if(a=='B')
{
cin>>u>>b;
if(book[b])
puts("The book is not in the library now");
else if(p[u].y>=)
puts("You are not allowed to borrow any more");
else
{
p[u].x[p[u].y++]=b;
book[b]=u;
puts("Borrow success");
}
}
else if(a=='R')
{
cin>>b;
if(book[b]==)
puts("The book is already in the library");
else
{
int poit;
u=book[b];
book[b]=;
for(int i=; i<p[u].y; i++)
{
if(p[u].x[i]==b)
{
poit=i;
break;
}
}
for(int i=poit; i<p[u].y-; i++)
p[u].x[i]=p[u].x[i+];
p[u].y--;
puts("Return success");
}
}
else if(a=='Q')
{
cin>>u;
if(p[u].y==)
puts("Empty");
else
{
int b[];
for(int i=; i<p[u].y; i++)
b[i]=p[u].x[i];
sort(b,b+p[u].y);
for(int i=; i<p[u].y; i++)
{
if(i==)
cout<<b[i];
else
cout<<" "<<b[i];
}
cout<<endl; }
}
}
cout<<endl;
}
return ;
}
Simple Library Management System HDU - 1497(图书管理系统)的更多相关文章
- 【HDOJ】1497 Simple Library Management System
链表. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXM 1001 #def ...
- Library management system design requirements
1)软件需求说明书 1. 引言 1.1 编写目的:本需求的编写是为了研究图书管理系统软件的开发途径和应用方法.同时它也是进行项目策划.概要设计和详细设计的基础,是维护人员进行内部维护,信息更新,验收和 ...
- 基于TXT文本的简单图书管理系统
1 ////////////////////////////////////////////////////////////////////////////////////// //SqList.h ...
- 使用类和对象、方法、循环、List、泛型来实现简单的图书管理系统
Book.java import java.util.List; import java.util.Scanner; public class Book { private String name; ...
- HR-人力资源管理系统(Human Resources Management System,HRMS)
人力资源管理系统(Human Resources Management System,HRMS),是指组织或社会团体运用系统学理论方法,对企业的人力资源管理方方面面进行分析.规划.实施.调整,提高企业 ...
- Node操作MongoDB并与express结合实现图书管理系统
Node操作MongoDB数据库 原文链接:http://www.xingxin.me/ Web应用离不开数据库的操作,我们将陆续了解Node操作MongoDB与MySQL这是两个具有代表性的数据库, ...
- C项目实践--图书管理系统(1)
1.功能需求分析 图书管理系统主要用于对大量的图书信息,包括书名.作者.出版社.出版日期.ISBN(书号)等进行增.删.改.查以及保存等操作.同时也包括对用户的管理,用户包括管理员和普通用户两种权限, ...
- C项目实践--图书管理系统(2)
前面在<<C项目实践-图书管理系统(1)>>中把系统中的三大功能模块中可能涉及到的常量,结构体及相关函数进行了声明定义,下来就来实现它们. 执行系统首先从登录到系统开始,所以首 ...
- 基于Android平台的图书管理系统的制作(2)
上一篇讲解了制作图书管理系统的初衷与要求,和app首页的代码. 下面来介绍图书管理系统的服务对象:学生 学生类的设计: 个人信息:账号.密码.姓名.学号.邮箱.年龄. 借阅信息:借阅总数(不超过十本) ...
随机推荐
- Fltiss项目的架构、包名的定义和类的划分
这是项目的一览 首先Web根目录. 除了WEB-INF以外,还有css,img,js,lib目录,这四者都是静态资源. 由于客户端无法访问WEB-INF下的内容,所以将它们放置在了Web根目录下. 而 ...
- 汇编语言学习-Dos下的调试工具debug的使用教程
1.常用的debug功能 (1)用Debug的R命令查看.改变CPU寄存器内容: (2)用Debug的D命令查看内存中的内容: (3)用Debug的E命令查看内存中的内容: (4)用Debug的U命令 ...
- OpenGL+VS2010环境配置及遇到的问题
OpenGL+VS2010+GLUT工具包+WIN10系统: 第一步,安装GLUT工具包 Windows环境下的GLUT下载地址:(大小约为150k) http://www.opengl.org/re ...
- CRT小键盘输入乱码
Options --> Session Options --> Terminal --> Emulation --> Modes 去选中 Enable keypad mode ...
- Hdu 5344
Hdu5344 题意: 给你一个数组,求所有的 $ a_i + a_j $ 的异或值. 解法: 因为 $ (a_i+a_j) \bigoplus (a_j + a_i) = 0$ . 所以答案就是 $ ...
- 基于OVS命令的VLAN实现
利用mininet创建如下拓扑,要求支持OpenFlow 1.3协议,主机名.交换机名以及端口对应正确 直接在Open vSwitch下发流表,实现如下连通性要求 h1 -- h4互通 h2 -- h ...
- 求N个集合的并集
做容器放置实验时,需要计算下载N个Images的总size(Image之间可能会有可以共享的size). 一开始想到的是Images两两之间求交集,然后慢慢推到了容斥原理...时间复杂度大概就是O(N ...
- selenium 配置 chromedriver
参考文档: https://blog.csdn.net/yoyocat915/article/details/80580066?tdsourcetag=s_pcqq_aiomsg http://npm ...
- 性能分析 | Java进程CPU占用高导致的网页请求超时的故障排查
一.发现问题的系统检查: 一个管理平台门户网页进统计页面提示请求超时,随进服务器操作系统检查load average超过4负载很大,PID为7163的进程占用到了800%多. 二.定位故障 根据这种故 ...
- 使用es6一句话去重
let arr = [1,2,3,4,5,1,2,3] let arr2 = Array.from(new Set(arr)) console.log(arr2) //[1,2,3,4,5]