Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <string>
- using namespace std;
- queue<string> stringDivide(string s)
- {
- string str = "";
- queue<string> que;
- for (int i = 0; i < s.length(); ++i)
- {
- if (s[i] == " ") {
- que.push(str);
- str = "";
- continue;
- }
- str += s[i];
- }
- return que;
- }
- void printQueue(queue<string> que)
- {
- for (string s : que) cout << s << " ";
- }
- int main()
- {
- string base;
- getline(cin, base);
- queue<string> que = stringDivide(base);
- char ch = que.front()[0].toUpper();
- que.pop();
- queue<string> firstIsSame, firstIsNotSame;
- int cnt = 0;
- while (que.size() != 0)
- {
- if (que.front()[0].toUpper == ch)
- {
- cnt++;
- firstIsSame.push(que.front());
- que.pop();
- }
- else
- {
- firstIsNotSame.push(que.front());
- que.pop();
- }
- }
- printQueue(firstIsSame);
- printQueue(firstIsNotSame);
- cout << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment