uva 814 The Letter Carrier's Rounds
来源:互联网 发布:淘宝卖的哈曼卡顿真假 编辑:程序博客网 时间:2024/05/18 02:35
题目:The Letter Carrier's Rounds
题意:输入MTA以及在同一个MTA中的所有人。再输入发件人和收件人以及信息的内容,要求整理成题目所示的格式输出。
思路:模拟题,将数据读入后按顺序输出。
注意:(1)注意按顺序输出,所以不能用map只能用vector存储。
(2)注意重复的情况要。
代码:
#include<cstdio>#include<iostream>#include<string>#include<vector>#include<set>#include<map>using namespace std;struct USER {string Before;string Name;string Adress;USER() {}USER(string x) {Before=x;}void spl() {int pos=Before.find('@');Name=Before.substr(0,pos);Adress=Before.substr(pos+1,Before.size()-pos);}};map<string,vector<string> > user;USER sender;vector<USER> rec;vector<string> Data;vector<string> mp;void init() {rec.clear();Data.clear();mp.clear();}int main() {string x;while(cin>>x&&x[0]!='*') {cin>>x;int num;cin>>num;for(int i=0; i<num; i++) {string y;cin>>y;user[x].push_back(y);}}while(cin>>sender.Before&&sender.Before[0]!='*') {init();sender.spl();while(cin>>x&&x[0]!='*') {bool flag=true;for(int i=0;i<rec.size();i++){if(rec[i].Before==x){flag=false;break;}}if(flag==false) continue;rec.push_back(USER(x));rec[rec.size()-1].spl();flag=true;for(int i=0;i<mp.size();i++){if(mp[i]==rec[rec.size()-1].Adress){flag=false;break;}}if(flag==true)mp.push_back(rec[rec.size()-1].Adress);}string d;getchar();while(getline(cin,d)&&d[0]!='*') {Data.push_back(d);}for(int it=0; it<mp.size(); it++) {cout<<"Connection between "<<sender.Adress<<" and "<<mp[it]<<endl;cout<<" HELO "<<sender.Adress<<endl;cout<<" 250\n";cout<<" MAIL FROM:<"<<sender.Before<<">\n";cout<<" 250\n";bool F=false;for(int i=0; i<rec.size(); i++) {if(rec[i].Adress==mp[it]) {cout<<" RCPT TO:<"<<rec[i].Before<<">\n";bool flag=false;for(int j=0; j<user[mp[it]].size(); j++) {if(user[mp[it]][j]==(rec[i].Name)) {F=true;flag=true;break;}}if(flag==false) cout<<" 550\n";else cout<<" 250\n";}}if(F==true) {cout<<" DATA\n 354\n";for(int i=0; i<Data.size(); i++) {cout<<" ";cout<<Data[i]<<endl;}cout<<" .\n 250\n";}cout<<" QUIT\n 221\n";}}return 0;}
阅读全文
2 0
- uva 814 The Letter Carrier's Rounds
- The letter Carrier's Rounds(Uva 814)
- uva 814 The Letter Carrier's Rounds
- The Letter Carrier's Rounds UVA
- UVa 814 - The Letter Carrier's Rounds(模拟)
- The Letter Carrier's Rounds(UVa 814)
- 814 - The Letter Carrier's Rounds
- 814 - The Letter Carrier's Rounds
- UVa 814 The Lettter Carrier's Rounds
- 例题5-11 UVA 814 The Letter Carrier’s Rounds邮件传输代理的交互
- UVa814 - The Letter Carrier's Rounds
- uva814-The letter Carrier's Rounds
- 814-The Letter Carrier's Rounds【模拟、STL、被坑了】
- VUA814-The Letter Carrier's Rounds(入门经典5-11,PE)
- How To get the usbdisk's drive letter properly
- Lesson Forty-Five The boss's letter. 老板的信.
- Lesson 45 The boss's letter 老板的信
- UVA The Sultan's Successors
- cpu load
- 【博客公告】
- LinkedHashmap源码剖析
- 各种场合的日期转换
- C语言:顺序,二分查找,冒泡排序实践项目
- uva 814 The Letter Carrier's Rounds
- Ubuntu16.04系统装机必做
- Zabbix 安装
- ubuntu 16.04 安装openCv3.1
- tomcat正常启动访问页面是空白页解决办法
- bzoj1942: [Ceoi2007]Ministry
- C++定义一个只能在堆上(栈上)生成对象的类
- HDU4691用RMQ求所有字符串后缀的最长公共前缀
- 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数P。并将P对1000000007取模的结果输出。 即输出P%100000000