省赛2D题
来源:互联网 发布:java xpath html 编辑:程序博客网 时间:2024/06/07 05:11
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2167
因为所有客户资料是与账户名挂钩的,所以以一个map做映射,做账户名和一个结构体的映射,结构体是cipher(string)和balance(int)。
#include <iostream>#include <map>#include <string>#include <stdio.h>using namespace std;typedef struct pwd_bal{string password;int balance;}p;int main(){int t;cin>>t;map<string, p> a;while(t--){char c;cin>>c;if(c == 'O'){string name;p temp;cin>>name>>temp.password>>temp.balance;if(a.insert(make_pair(name,temp)).second){cout<<"Successfully opened an account."<<endl;}else{cout<<"Account exists."<<endl;}}else if(c == 'D'){string name;int money;cin>>name>>money;map<string,p>::iterator it = a.find(name);if(it != a.end()){(it->second).balance += money;cout<<"Successfully deposited money."<<endl;}else{cout<<"Account does not exist."<<endl;}}else if(c == 'W'){string name, password;int money;cin>>name>>password>>money;map<string,p>::iterator it = a.find(name);if(it != a.end()){if((it->second).password == password){if((it->second).balance >= money){(it->second).balance -= money;cout<<"Successfully withdrew money."<<endl;}else{cout<<"Money not enough."<<endl;}}else{cout<<"Wrong password."<<endl;}}else{cout<<"Account does not exist."<<endl;}}else if(c == 'T'){string name1, password, name2;int money;cin>>name1>>password>>name2>>money;map<string,p>::iterator it = a.find(name1);map<string,p>::iterator itt = a.find(name2);if(it != a.end() && itt != a.end()){if((it->second).password == password){if((it->second).balance >= money){(it->second).balance -= money;(itt->second).balance += money;cout<<"Successfully transfered money."<<endl;}else{cout<<"Money not enough."<<endl;}}else{cout<<"Wrong password."<<endl;}}else{cout<<"Account does not exist."<<endl;}}else if(c == 'C'){string name, password;cin>>name>>password;map<string,p>::iterator it = a.find(name);if(it != a.end()){if((it->second).password == password){cout<<(it->second).balance<<endl;}else{cout<<"Wrong password."<<endl;}}else{cout<<"Account does not exist."<<endl;}}else if(c == 'X'){string name, password1, password2;cin>>name>>password1>>password2;map<string,p>::iterator it = a.find(name);if(it != a.end()){if((it->second).password == password1){(it->second).password = password2;cout<<"Successfully changed password."<<endl;}else{cout<<"Wrong password."<<endl;}}else{cout<<"Account does not exist."<<endl;}}}}
另外,今天在帮胖胖和一宁查错的时候,学习了一个新插件,Notepad++的compare,直接在plugin安装那里选择最新的稳定的版本即可,查错十分方便。
- 省赛2D题
- 北邮赛2题D
- (@"^-?\d+(\.\d{2})?$");解释
- Codeforces 615D Multipliers (Round #338 (Div. 2) D题)
- Codeforces 617D Polyline (Round #340 (Div. 2) D题)
- D题
- 2d
- 输出printf 时 %2d,%d,%02d,%.2d
- 2d , 3d engine
- Quartz 2D 绘图d
- 2D转3D
- 1D 2D 混合
- animal 2D 3D
- ZOJ 3872 2015省赛D 技巧题
- Codeforces 182 Div.2 D题
- Codeforces Round #261 (Div. 2) D题
- Codeforces Round #277 (Div. 2)D题
- codeforces#291(div.2)D题
- C语言中堆和栈的区别
- C++全局对象的析构函数有时候没有被调用?非也!(编译器为VC++6.0)
- Archlinux上fcitx怎麼才能輸入正體中文
- 1096最小生成树
- The Android University ACM Team Selection Contest
- 省赛2D题
- 在linux-2.6.33.5内核中添加对s3c2410串口2的配置
- undefined reference to错误的解决方法
- fstab修改有误导致无法启动的解决方法
- J2EE (三) Filter详解
- C++ 智能指针详解
- jshoper3x在线商城系统更新说明及未来开发计划
- ARP协议分析
- ubuntu快捷键