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