[2011山东ACM省赛] Mathman Bank(模拟题)

时间:2021-02-03 13:56:25

版权声明:本文为博主原创文章,未经博主同意不得转载。

https://blog.csdn.net/sr19930829/article/details/24187925

Mathman Bank

nid=24#time" rel="nofollow" style="color:rgb(83,113,197);text-decoration:none;">

Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描写叙述

 With the development of mathmen's mathematics knowlege, they have finally invented
computers. Therefore, they want to use computers to manage their banks. However, mathmen's programming skills are not as good as their math-
ematical skills. So they need your help to write a bank management system software.

The
system must support the following operations:

1.
Open account: given the customer's name and password, and an initial deposit,
open an bank account for the customer.

2.
Deposit: given the amount of money and the name of the customer, deposit
money in the customer's account.

3.
Withdraw: given the amount of money, the customer's name and password,
withdraw money from the customer's account.

4.
Transfer: given the amount of money, sender's name, sender's password and
receiver's name, transfer money from the sender's account to the

receiver's
account.

5.
Check: given the customer's name and password, print the balance of the
customer's account.

6.
Change password: given the customer's name and old password, and the
new password, replace the customer's old password with the new one.

Initially,
no account exists in the bank management system .

输入

 The first line of the input contains one positive integer, n (n <= 1000), which is
the number of commands. Each of the following n lines contains one of the following commands, in the
following format:

1.
O "customer" "password" "initial deposit" - open an account for "customer",
set the password to "password" and deposit "inital deposit" money
in the account. "customer" and "password" are strings, and "initial
deposit" is an integer.

2.
D "customer" "amount" - deposit "amount" money in "customer"'sac-
count. "customer" is a string, and "amount" is an integer.

3.
W"customer" "password" "amount" - withdraw "amount" money from "customer"'s
account. "customer" and "password" are strings, and amount

4.
T "sender" "password" "receiver" "amount" - transfer "amount" money from
"sender"'s acount to "receiver"'s account. "sender", "pasword" and
"receiver" are strings, and "amount" is an integer. 

5.
C "customer" "password" - check "customer"'s balance. "customer" and
"password" are strings.

6.
X "customer" "old password" "new password" - replace "customer"'s old
password with "new password". "customer", "old password" and "new
password" are strings.

All
of the strings appearing in the input consist of only alphebetical letters and
digits, and has length at most 10. All the integers in the input are nonnegative,
and at most 1000000.

Refer
to the sample input for more details.

输出

For each of the commands, output one of the following results, respectively:

1.
Open account: If "customer" already has an account, output "Account
exists." (without quotation marks); otherwise, output "Successfully
opened an account." (without quotation marks).

2.
Deposite: If "customer" doesn't have an account ,output "Account does not
exist."; otherwise, output "Successfully deposited money."(without quotation
marks).

3.
Withdraw: If "customer" doesn't have an account, output "Account does
not exist."; otherwise, if "customer"'s password doesn't match "password",
output "Wrong password."; otherwise, if there are less money
than "amount" in "customer"'s account, output "Money not enough.";
otherwise, output "Successfully withdrew money." quotation marks).

4.
Transfer: If "sender"'s account or "receiver"'s account doesn't exist,
output "Account does not exist."; otherwise, if "sender"'s password
doesn't match "password", output "Wrong password."; otherwise,
if there is less money than 'amount" in "sender"'s account, output
"Money not enough."; otherwise, output "Successfully transfered money."

5.
Check: If "customer"'s account doesn't exist, output "Account does not
exist."; otherwise, if "customer"'s password doesn't match "password",
output "Wrong password."; otherwise, output the balance of "customer"'s
account.

6.
Change password: If "customer" doesn't have an account, output "Account
does not exist."; otherwise, if "customer"'s password doesn't match
"old password", output "Wrong password."; otherwise, output 'Successfully
changed password.".

演示样例输入

25
W Alice alice 10
O Alice alice 10
C Alice alice
D Bob 10000
O Bob bob 100
D Alice 50
C Alice alice
X Bob bob BOB
C Bob bob
O Bob bob 10
T Bob bob Alice 100000
W Alice alice 10
T Bob BOB Alice 100000
T Bob BOB Alice 100
C Alice alice
C Bob BOB
T Alice alice BOB 10
T ALICE alice Bob 10
X Jack jack JACE
X Alice ALICE alice
W Alice Alice 10
W Alice alice 200
T Alice alice Bob 80
C Alice alice
C Bob BOB

演示样例输出

Account does not exist.
Successfully opened an account.
10
Account does not exist.
Successfully opened an account.
Successfully deposited money.
60
Successfully changed password.
Wrong password.
Account exists.
Wrong password.
Successfully withdrew money.
Money not enough.
Successfully transfered money.
150
0
Account does not exist.
Account does not exist.
Account does not exist.
Wrong password.
Wrong password.
Money not enough.
Successfully transfered money.
70
80

提示

 

来源

山东省第二届ACM大学生程序设计竞赛

 

解题思路:

模拟银行开设账户,存款,取款。转账等业务,题目没难度,依照题意模拟,写代码时要细致。

[2011山东ACM省赛] Mathman Bank(模拟题)

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc3JfMTk5MzA4Mjk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" />

代码:

#include <iostream>
#include <string.h>
using namespace std; struct Node//为每一个账户开设一个结构体
{
string Name;//姓名
string Code;//密码
int Money;//存款金额
}node[1002]; int find(Node x[],int m,string name)//两个功能,推断name是否已经开了账户,假设已经开了返回在数组中的位置
{
for(int i=0;i<m;i++)
{
if(x[i].Name==name)
{
return i;
}
}
return -1;
} int main()
{
int n;char cm;
int m=0;
cin>>n;
while(n--)
{
cin>>cm;
if(cm=='O')//开设账户
{
string name,code;
int money;
cin>>name>>code>>money;
if(find(node,m,name)==-1||m==0)//该姓名没有开账户
{ node[m].Name=name;
node[m].Code=code;
node[m].Money=money;
m++;
cout<<"Successfully opened an account."<<endl;
}
else
cout<<"Account exists."<<endl;
}
if(cm=='D')
{
string name;int money;
cin>>name>>money;
if(find(node,m,name)==-1)
cout<<"Account does not exist."<<endl;
else
{
node[find(node,m,name)].Money+=money;
cout<<"Successfully deposited money."<<endl;
}
}
if(cm=='W')
{
string name,code;int money;
cin>>name>>code>>money;
if(find(node,m,name)==-1)
{
cout<<"Account does not exist."<<endl;
}
else
{
if(node[find(node,m,name)].Code!=code)
{
cout<<"Wrong password."<<endl;
}
else if(node[find(node,m,name)].Money<money)
{
cout<<"Money not enough."<<endl; }
else
{
node[find(node,m,name)].Money-=money;
cout<<"Successfully withdrew money."<<endl;
}
} }
if(cm=='T')
{
string name1,code,name2;
int money;
cin>>name1>>code>>name2>>money;
if(find(node,m,name1)==-1||find(node,m,name2)==-1)
cout<<"Account does not exist."<<endl;
else if(node[find(node,m,name1)].Code!=code)
cout<<"Wrong password."<<endl;
else if(node[find(node,m,name1)].Money<money)
cout<<"Money not enough."<<endl;
else
{
node[find(node,m,name1)].Money-=money;
node[find(node,m,name2)].Money+=money;
cout<<"Successfully transfered money."<<endl;
}
}
if(cm=='C')
{
string name,code;
cin>>name>>code;
if(find(node,m,name)==-1)
{
cout<<"Account does not exist."<<endl;
}
else if(node[find(node,m,name)].Code!=code)
{
cout<<"Wrong password."<<endl;
}
else
{
cout<<node[find(node,m,name)].Money<<endl;
}
}
if(cm=='X')
{
string name,code1,code2;
cin>>name>>code1>>code2;
int len=find(node,m,name);
if(len==-1)
{
cout<<"Account does not exist."<<endl;
}
else if(node[len].Code!=code1)
{
cout<<"Wrong password."<<endl;
}
else
{
node[len].Code=code2;
cout<<"Successfully changed password."<<endl;
}
} } return 0;
}

 

 

[2011山东ACM省赛] Mathman Bank(模拟题)的更多相关文章

  1. &lbrack;2011山东ACM省赛&rsqb; Identifiers(模拟)

    Identifiers Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描写叙述  Identifier is an important ...

  2. &lbrack;2011山东ACM省赛&rsqb; Sequence (动态规划)

    Sequence Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Given an integer number sequence ...

  3. &lbrack;2011山东ACM省赛&rsqb; Binomial Coeffcients(求组合数)

    Binomial Coeffcients nid=24#time" style="padding-bottom:0px; margin:0px; padding-left:0px; ...

  4. &lbrack;2012山东ACM省赛&rsqb; Pick apples (贪心,完全背包,枚举)

    Pick apples Time Limit: 1000MS Memory limit: 165536K 题目描述 Once ago, there is a mystery yard which on ...

  5. &lbrack;2012山东ACM省赛&rsqb; Pick apples (贪心,全然背包,枚举)

    Pick apples Time Limit: 1000MS Memory limit: 165536K 题目描写叙述 Once ago, there is a mystery yard which ...

  6. 山东ACM省赛历届入口

    山东省第一届ACM大学生程序设计竞赛 山东省第二届ACM大学生程序设计竞赛 山东省第三届ACM大学生程序设计竞赛 山东省第四届ACM大学生程序设计竞赛 山东省第五届ACM大学生程序设计竞赛 山东省第六 ...

  7. &lbrack;2013山东ACM&rsqb;省赛 The number of steps (可能DP,数学期望)

    The number of steps nid=24#time" style="padding-bottom:0px; margin:0px; padding-left:0px; ...

  8. hdu 4023 2011上海赛区网络赛C 贪心&plus;模拟

    以为是贪心,结果不是,2333 贪心最后对自己绝对有利的情况 点我 #include<cstdio> #include<iostream> #include<algori ...

  9. 第八届山东ACM省赛F题-quadratic equation

    这个题困扰了我长达1年多,终于在今天下午用两个小时理清楚啦 要注意的有以下几点: 1.a=b=c=0时 因为x有无穷种答案,所以不对 2.注意精度问题 3.b^2-4ac<0时也算对 Probl ...

随机推荐

  1. Storm

    2016-11-14  22:05:29 有哪些典型的Storm应用案例? 数据处理流:Storm可以用来处理源源不断流进来的消息,处理之后将结果写入到某个存储中去.不像其它的流处理系统,Storm不 ...

  2. C&num; 利用NPOI 实现Excel转html

    public void ExcelToHtml(string fileName, IWorkbook workbook) { ExcelToHtmlConverter excelToHtmlConve ...

  3. eclipse插件在线发布发布和版本更新&lpar;web site&rpar; 转

    欢迎关注我的社交账号: 博客园地址: http://www.cnblogs.com/jiangxinnju/p/4781259.html GitHub地址: https://github.com/ji ...

  4. Office word excel电子表格在线编辑的实现方法

    Office xp之后的版本支持通过webdav协议(http的扩展)直接编辑服务器上的文件. IIS(6.0)支持webdav,这在IIS管理器的web服务扩展中可以看到.利用IIS作为webdav ...

  5. java中File类的常用所有方法及其应用

    创建:createNewFile()在指定位置创建一个空文件,成功就返回true,如果已存在就不创建,然后返回false.mkdir()  在指定位置创建一个单级文件夹.mkdirs()  在指定位置 ...

  6. &lbrack;Postman&rsqb;发出SOAP请求&lpar;18&rpar;

    使用Postman发出SOAP请求: 将SOAP端点作为URL.如果您使用的是WSDL,那么请将WSDL的路径作为URL. 将请求方法设置为POST. 打开原始编辑器,并将正文类型设置为“text / ...

  7. 解决Response&period;AddHeader&lpar;&quot&semi;Content-Disposition&quot&semi;&comma; &quot&semi;attachment&semi; filename&equals;&quot&semi; &plus; file&period;Name&rpar; 中文显示乱码

    如果file.Name为中文则乱码.解决办法是方法1:response.setHeader("Content-Disposition", "attachment; fil ...

  8. Vbs脚本简单使用

    之前在做项目时用到了一点vbs脚本,记录下. C++程序调用vbs脚本 System(vbs路径 参数); //空格隔开 Vbs脚本 '''''Vbs脚本解析参数 Set objArgs = Wscr ...

  9. AEAI DP开发统计分析

    1 背景概述 平时做统计分析都是调rest服务,给前台提供数据,然后在管理控制台里配置portlet.但并不是所有的项目都会用到portal,这时就需要在AEAI DP应用开发平台里开发统计分析了,下 ...

  10. appium自动化---activity获取

    方法一:appt查询activity获取 aapt dump badging <路径/包名> | find "launchable-activity" 方法二: 1.打 ...