标签:size ddd 要求 一个 output isa cto format eee
#include <iostream> #include <map> #include <set> using namespace std; int main() { string s; while(getline(cin, s)) { map<char, int> mmp; set<string> ss; string str; for(int i = 0; i < s.length(); i++) { if(isalpha(s[i])) str += s[i]; if(s[i] == ‘ ‘ || s[i] == ‘,‘ || s[i] == ‘.‘ || i == s.length() - 1) { if(str != "") { ss.insert(str); str = ""; } } } for(auto i = ss.begin(); i != ss.end(); i++) { string word = *i; mmp[word[0]]++; } for(auto i = mmp.begin(); i != mmp.end(); i++) { cout << i ->first << "," << i -> second << endl; } } return 0; }
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { string s; while(getline(cin, s)) { vector<string> ss; string str; for(int i = 0; i < s.length(); i++) { if(isalpha(s[i])) str += s[i]; if(s[i] == ‘ ‘ || s[i] == ‘,‘ || s[i] == ‘.‘ || i == s.length() - 1) { if(str != "") { ss.push_back(str); str = ""; } } } sort(ss.begin(), ss.end()); for(int i = 0; i < ss.size(); i++) { cout << ss[i] << " "; } } return 0; }
#include <iostream> #include <vector> #include <stack> #include <map> using namespace std; struct person { string name = ""; string leadername = ""; }; int main() { string s, s2; while (cin >> s >> s2) { vector<person> vp; vector<vector<string>> v; stack<string> sp; map<string, string> mmp; string str = ""; for (int i = 0; i < s.length(); i++) { if (isalpha(s[i])) str += s[i]; else { person p; if (str != ""){ p.name = str; if(!sp.empty()) { p.leadername = sp.top(); mmp[p.name] = sp.top(); } str = ""; } if(s[i] == ‘(‘) { if(p.name != "") sp.push(p.name); } if (s[i] == ‘)‘ && !sp.empty()) sp.pop(); if(p.name != "") vp.push_back(p); } } stack<string> ss; while(mmp[s2] != "") { ss.push(s2); s2 = mmp[s2]; } ss.push(s2); int num = ss.size(), cnt = 0; while(!ss.empty()) { cout << ss.top(); ss.pop(); cnt++; if(cnt < num) cout << ">"; } } return 0; }
PS:好几天都没状态了,得赶快进入状态啊!!!
标签:size ddd 要求 一个 output isa cto format eee
原文地址:https://www.cnblogs.com/ache/p/12563394.html