Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <set>
- #include <vector>
- using namespace std;
- set<string> commands_set(string& commands) {
- commands = " " + commands;
- int commands_num = commands.size() / 3;
- string next_command;
- set<string> keys;
- while (commands.size() > 1) {
- next_command = commands.substr(1, 2);
- keys.insert(next_command);
- commands = commands.substr(3);
- }
- return keys;
- }
- int main() {
- string commands;
- getline(cin, commands);
- set<string> keys = commands_set(commands);
- string str;
- int strings_num = 0;
- int symbols_num = 0;
- int max_length = 0;
- int words_num = 0;
- int tabs_num;
- while (getline(cin, str)) {
- strings_num++;
- symbols_num += str.size() + 1;
- if (str.size() > max_length) {
- max_length = str.size();
- }
- bool is_previos_alpha = false;
- for (char c : str) {
- if (isalpha(c)) {
- if (!is_previos_alpha) {
- words_num++;
- }
- is_previos_alpha = true;
- } else {
- is_previos_alpha = false;
- }
- }
- }
- bool is_first = true;
- if (keys.find("-l") != keys.end()) {
- cout << strings_num;
- is_first = false;
- }
- if (keys.find("-w") != keys.end()) {
- if (!is_first) {
- cout << " ";
- }
- cout << words_num;
- is_first = false;
- }
- if (keys.find("-m") != keys.end()) {
- if (!is_first) {
- cout << " ";
- }
- cout << symbols_num;
- is_first = false;
- }
- if (keys.find("-L") != keys.end()) {
- if (!is_first) {
- cout << " ";
- }
- cout << max_length;
- is_first = false;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement