Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <stdlib.h>
- #include <vector>
- using namespace std;
- char Change2Low(char c) {
- if (c <= 'Z' && c >= 'A') {
- return (c + static_cast<char>(32));
- } else {
- return (c);
- }
- }
- int main() {
- vector <string> v;
- string keys, sprev, s0;
- int count = 1;
- getline(cin, keys);
- bool c = 0, d = 0, i = 0, u = 0;
- for (int j = 0; j < keys.size(); ++j) {
- if (keys[j] == 'c') {
- c = 1;
- }
- if (keys[j] == 'd') {
- d = 1;
- }
- if (keys[j] == 'i') {
- i = 1;
- }
- if (keys[j] == 'u') {
- u = 1;
- }
- }
- getline(cin, sprev);
- if (i) {
- for (int j = 0; j < sprev.size(); ++j) {
- sprev[j] = Change2Low(sprev[j]);
- }
- }
- v.push_back(sprev);
- getline(cin, s0);
- while (s0 != "0") {
- v.push_back(s0);
- getline(cin, s0);
- }
- s0 = "";
- v.push_back(s0);
- for (int i = 1; i < v.size(); ++i) {
- if (!(u && d)) {
- if (i) {
- for (int j = 0; j < v[i].size(); ++j) {
- v[i][j] = Change2Low(v[i][j]);
- }
- }
- if (v[i] == v[i-1]) {
- ++count;
- } else {
- if (u && count == 1) {
- if (c) {
- cout << "1 " << v[i-1] << endl;
- } else {
- cout << v[i-1] << endl;
- }
- }
- if (d && count != 1) {
- if (c) {
- cout << count << " " << v[i-1] << endl;
- } else {
- cout << v[i-1] << endl;
- }
- }
- if (!d && !u) {
- if (c) {
- cout << count << " " << v[i-1] << endl;
- } else {
- cout << v[i-1] << endl;
- }
- }
- count = 1;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement