UVA 814 MTA 模拟
来源:互联网 发布:霍建华与林心如 知乎 编辑:程序博客网 时间:2024/05/16 15:06
#include<iostream>#include<vector>#include<map>#include<set>#include<string>//#define LOCAL#include<cstdio>using namespace std;void getInformation(string& ss, string user, string & mat){ int k = ss.find('@'); user = ss.substr(0, k); mat = ss.substr(k+1);}int main(){ #ifdef LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif // LOCAL int n; string s, t, s1, s2, mta1, mta2, user1, user2; // 对MAT进行整理 , 变成 姓名@地址的形式. set<string> adds; while(cin >> s1 && s1 != "*"){ cin >> s >> n; while(n--){ cin >> s2; adds.insert(s2 + "@" + s); } } // 处理发件人的信息, 把姓名和地址分开 while(cin >> s && s != "*") { getInformation(s, user1, mta1); // 关于字符串的处理 vector<string> mta; map<string, vector<string> > dest; set<string> vis; while(cin >> t && t != "*") { getInformation(t, user2, mta2); if(vis.count(t)) continue; // 重复的收件人, 直接跳过后续工作 vis.insert(t); if(!dest.count(mta2)) { mta.push_back(mta2); dest[mta2] = vector<string>();} dest[mta2].push_back(t); } getline(cin, t); // 正文的处理,整合成一句话 string data; while(getline(cin, t) && t != "*") data += " " + t + "\n"; // 对信息内容的处理 for(int i = 0; i < mta.size(); i++) { string mta2 = mta[i]; vector<string> users = dest[mta2]; cout << "Connection between " << mta1 << " and " << mta2 << endl; cout << " HELO " << mta1 <<endl << " 250" <<endl; cout << " MAIL FROM:<" << s << ">" << endl << " 250" <<endl; bool ok = false; for(int i = 0; i < users.size(); i++){ cout << " RCPT TO:<" << users[i] << ">" <<endl ; if(adds.count(users[i])) {ok = true; cout << " 250\n";} else cout << " 550\n"; } if(ok) { cout << " DATA\n"; cout << " 354\n"; cout << data; cout << " .\n" <<" 250\n"; } cout << " QUIT\n" << " 221\n"; } } return 0;}
0 0
- UVA 814 MTA 模拟
- UVA 814 SMTP协议模拟
- MUA & MTA
- UVA 10196 模拟题。。
- UVa 100 简单模拟
- UVa 602 简单模拟
- Uva 11039(排序+模拟)
- UVA 11039 模拟
- UVa 10189 Minesweeper (模拟)
- uva 11995 STL模拟
- uva 10205 模拟
- UVA 514 - Rails(模拟)
- uva 502(模拟)
- uva--188+模拟
- UVA Palindromes(模拟)
- UVA Artificial Intelligence?(模拟)
- UVA 401-Palindromes(模拟)
- UVa 227 模拟
- Linux wget命令
- Python操作redis
- OSI七层模型
- oracle 锁表进程SQL 处理
- 重载和重写的对比
- UVA 814 MTA 模拟
- 清除“浮动”影响
- 【SSLGZ 2646】线段树练习三
- 基于Token的WEB后台认证机制
- PCA的MATLAB实现
- iOS之有关视图偏移的问题
- 怎么应用vertical-align,才能生效?
- 常见的排序算法示例(3)-归并排序、堆排序
- SpringMail发送QQ邮件