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首页的代码. 下面来介绍图书管理系统的服务对象:学生 学生类的设计: 个人信息:账号.密码.姓名.学号.邮箱.年龄. 借阅信息:借阅总数(不超过十本) ...
随机推荐
- Shell基础之四 变量与运算
shell变量与运算 变量存在于内存中.假设变量str,设置或修改变量属性时,不带$号,只有引用变量的值时才使用$号.也就是说在内存中,标记变量的变量名称是str,而不是$str. 变量数据的存储方式 ...
- Mac下持续集成-与JMeter与Ant执行后自动发送邮件的整合(性能报告)==
配置信息如下,其他的为默认的: 添加性能测试报告后,性能测试报告部分构件失败:
- 完全背包---P1679 神奇的四次方数
P1679 神奇的四次方数 题解 一看这就是个完全背包 m最多不会超过18^4,所以我们把x^4用数组存起来,然后考虑如何填满m,注意存到18^4,不然会像我一样RE... 那么问题就转化成完全背包问 ...
- oracle传输表空间
https://blog.csdn.net/ch7543658/article/details/39271135/ Oracle expdp/impdp常用性能优化方法 1.查看操作系统endiann ...
- Flask之加载静态资源
Flask之加载静态资源 1.加载css样式 <link rel="stylesheet" href="{{ url_for('static',filename=' ...
- yum -y与 yum有什么区别
在linux中,经常使用yum来进行软件的安装,更新与卸载,那我们会发现,在使用yum的时候,通常有下面两种指令模式: ①yum install xxx ②yum -y install xx 那这 ...
- ubuntu tensorflow cpu faster-rcnn train data
(flappbird) luo@luo-All-Series:~/MyFile/tf-faster-rcnn_box$ (flappbird) luo@luo-All-Series:~/MyFile/ ...
- 原生js实现深复制
function deepClone (obj) { if (obj === null) { // 如果是null则直接返回 return obj; } let copy = Array.isArra ...
- 假如React没了JSX
如题,想必React大家早已不陌生,而React里面的JSX都是玩的得心应手了,但是假如说React里面没有了React那会是一种什么样的情形呢,我们来简单的看一下. 首先我们来实现一个简单的list ...
- Apache Spark大数据分析入门(一)
摘要:Apache Spark的出现让普通人也具备了大数据及实时数据分析能力.鉴于此,本文通过动手实战操作演示带领大家快速地入门学习Spark.本文是Apache Spark入门系列教程(共四部分)的 ...