#include <iostream>
#include <map>
#include <vector>
#include <string>
using namespace std;
int main(){
string s;
char key;
char value;
map<char, vector<char> > map_level1;
map<char, vector<char> > map_level2;
while (getline(cin, s)){
if (s == "eof"){
break;
}
key = s[0];
value = s[2];
//not in both
if (map_level1.find(key) == map_level1.end() && map_level2.find(key) == map_level2.end()){
map_level1[key].push_back(value);
map_level2[value];
}else if (map_level1.find(key) == map_level1.end()){ //key only in map2
map_level2[key].push_back(value);
}else //key only in map1
{
map_level1[key].push_back(value); //only in map1
if (map_level2.find(value) == map_level2.end()){ //value not in map2
map_level2[value];
}
}
}
map<char, vector<char> >::iterator it = map_level1.begin();
map<char, vector<char> >::iterator it_end = map_level1.end();
for (; it != it_end; it++){
cout << it->first << endl;
//vec in level1
for (int i = 0; i < map_level1[it->first].size(); i++){
cout <<" "<< map_level1[it->first][i] << endl;
//in map2
if (map_level2.find(map_level1[it->first][i]) != map_level2.end()){
for (int j = 0; j < map_level2[map_level1[it->first][i]].size(); j++){
cout <<" "<< map_level2[map_level1[it->first][i]][j] << endl;
}
}
}
}
getchar();
return 0;
}
[sth]xx
相關文章
- "mv" all the stuffs excluding sth
- Oracle案例08——xx.xx.xx.xx,表空間 SYSAUX 使用率>95%%OracleUX
- HTTP的response code 1xx,2xx,3xx,4xx,5xx分別代表什麼HTTP
- navicat無法連線遠端的mysql--Host ‘xx.xx.xx.xx‘ is not allowed to connect to this MySQL server“MySqlServer
- SharePlex reader missed marker wait for xx but got xxAIGo
- appscan 遇到 xx.xx.xx.xx/8080/web/#/url,是不是就不能識別延伸的網址啦。。APPWeb
- JAVA -Xms -Xmx -XX:PermSize -XX:MaxPermSize 區別Java
- 簡介響應狀態碼1xx、2xx、5xx
- Go 自定義日期時間格式解析解決方案 - 解決 `parsing time xx as xx: cannot parse xx as xx` 錯誤Go
- Maven - Non-resolvable parent POM: Failure to find xx:xx:pomMavenAI
- 小知識點 之 JVM -XX:MaxGCPauseMillis 與 -XX:GCTimeRatioJVMGC
- XX外賣專案
- The directory xx is registered as a Git rootGit
- NRF528XX說明
- 【Nginx實戰】構建NGINX 4xx 5xx 狀態碼例項Nginx
- JD+XX金融的面試面試
- xx開啟了朋友驗證
- 記錄oracle中查詢資料0.xx結果為.xx的解決辦法Oracle
- 【問題解決】java.sql.SQLException: null, message from server: “Host ‘xxx.xx.xx.xxx‘ is blocked because ofJavaSQLExceptionNullServerBloC
- 記一次XX前端面試前端面試
- Elasticsearch報Call to undefined xx makeAllSearchable()錯誤ElasticsearchUndefined
- PHP程式報錯:PHP Notice: Undefined index: XX inPHPUndefinedIndex
- windows下pip install xx 遇到的 ConnectionResetError問題WindowsError
- python中 _、__、__xx__() 區別及使用場景Python
- -XX:PretenureSizeThreshold的預設值和作用淺析
- Angular 錯誤訊息:ERROR Error NullInjectorError No provider for XXAngularErrorNullIDE
- 深圳XX機器人前端開發面試機器人前端面試
- windows下用XX-Net+ipv6+Chrome翻牆WindowsChrome
- 菜鳥學Python之 _, __ 和 __xx__的區別Python
- STM32F4XX LWIP+freeRTOS移植(一)
- 我天!xx.equals(null) 是什麼騷操作??Null
- 你會去玩一款“類XX”遊戲嗎?遊戲
- 3xx HTTP狀態碼的終極指南HTTP
- JVM異常不列印堆疊資訊 [ -XX:-OmitStackTraceInFastThrow ]JVMMITAST
- 沙師弟學Python之 _, __ 和 __xx__的區別Python
- SQLSERVER事務日誌已滿 the transaction log for database 'xx' is fullSQLServerDatabase
- “XX黑魂”這麼多,到底什麼是魂like?
- 解決The given version [xx] is not supported, only version 1 to 10 is supported in this buildUI