5-05. QQ帐户的申请与登陆STL

来源:互联网 发布:xp如何连接网络打印机 编辑:程序博客网 时间:2024/04/30 00:26

STL map的使用(红黑树)

// QQ帐户的申请与登陆.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <stdio.h>#include <map>#include <string>using namespace std;map<int,string> cmap;int _tmain(int argc, _TCHAR* argv[]){int n;scanf("%d", &n);while(n--){char cmdLine[3];int id;char pwd[20];scanf("%s%d%s", cmdLine, &id, pwd);string sstr = pwd;if(cmdLine[0] == 'N'){if(cmap.find(id) == cmap.end()){cmap[id] = sstr;printf("New: OK\n");}else{printf("ERROR: Exist\n");}}else{if(cmap.find(id) == cmap.end())printf("ERROR: Not Exist\n");else{if(sstr != cmap[id])printf("ERROR: Wrong PW\n");elseprintf("Login: OK\n");}}}return 0;}


原创粉丝点击