当前位置: 首页 > article >正文

浙大数据结构:11-散列3 QQ帐户的申请与登陆

哈希表应用使用map,所以写起来并不难

1、主函数

感觉有点像map的简单应用,把所有条件都进行处理判断就行

#include <iostream>
#include<string>
#include<unordered_map>
#include<algorithm>
using namespace std;
#define endl '\n'


int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  unordered_map<string ,string>m;
  int n;
  cin>>n;
  while(n--)
  {
    string person,account,password;
    cin>>person>>account>>password;
    if(person=="L")
    {
      if(m.find(account)==m.end())
      {
        cout<<"ERROR: Not Exist"<<endl;
        continue;
      }
      else if(m[account]!=password)
      {
        cout<<"ERROR: Wrong PW"<<endl;
        continue;
      }
      cout<<"Login: OK"<<endl;
    }
    else{
        if(m.find(account)!=m.end())
        {
          cout<<"ERROR: Exist"<<endl;
          continue;
        }
        m[account]=password;
        cout<<"New: OK"<<endl;
    }
  }
  return 0;
}


http://www.kler.cn/a/349125.html

相关文章:

  • 植物大战僵尸杂交版
  • 运行Springboot + Vue 项目
  • 回归本真 治愈心灵——汪青《在西行的路上》
  • 地平线与英伟达工具链 PTQ 工具功能参数对比与实操
  • Linux下以编译源码的方式安装Qt5与Qt6及其使用
  • AB路线——BFS+分层图
  • Git---Git打标签
  • ui入门
  • Antsword-labs靶机渗透
  • Python基础语法条件
  • 基础IO -- 理解文件(1)
  • 使用tgz包下载安装clickhouse低版本
  • BERT--详解
  • 嵌入式Linux:信号掩码
  • 写一篇assignment的感悟
  • Python爬虫之正则表达式于xpath的使用教学及案例
  • Flutter资源管理(四)
  • LeetCode209.长度最小的子数组
  • 基于yolov8、yolov5的烟雾检测系统(含UI界面、训练好的模型、Python代码、数据集)
  • 【Vue】Vue2(7)