Advertisement
dmitryokh

Untitled

Dec 14th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4. #include <stdlib.h>
  5.  
  6. using namespace std;
  7.  
  8. char Change2Low(char c) {
  9. if (c <= 'Z' && c >= 'A') {
  10. return (c + static_cast<char>(32));
  11. } else {
  12. return (c);
  13. }
  14. }
  15.  
  16. int main() {
  17. string keys, sprev, s0;
  18. int count = 1;
  19. getline(cin, keys);
  20. bool c = 0, d = 0, i = 0, u = 0;
  21. for (int j = 0; j < keys.size(); ++j) {
  22. if (keys[j] == 'c') {
  23. c = 1;
  24. }
  25. if (keys[j] == 'd') {
  26. d = 1;
  27. }
  28. if (keys[j] == 'i') {
  29. i = 1;
  30. }
  31. if (keys[j] == 'u') {
  32. u = 1;
  33. }
  34. }
  35. getline(cin, sprev);
  36. if (i) {
  37. for (int j = 0; j < sprev.size(); ++j) {
  38. sprev[j] = Change2Low(sprev[j]);
  39. }
  40. }
  41. while (getline(cin, s0)) {
  42. if (!(u && d)) {
  43. if (i) {
  44. for (int j = 0; j < s0.size(); ++j) {
  45. sprev[j] = Change2Low(sprev[j]);
  46. }
  47. }
  48. if (s0 == sprev) {
  49. ++count;
  50. } else {
  51. if (u && count == 1) {
  52. if (c) {
  53. cout << "1 " << sprev << endl;
  54. } else {
  55. cout << sprev << endl;
  56. }
  57. }
  58. if (d && count != 1) {
  59. if (c) {
  60. cout << count << " " << sprev << endl;
  61. } else {
  62. cout << sprev << endl;
  63. }
  64. }
  65. if (!d && !u) {
  66. if (c) {
  67. cout << count << " " << sprev << endl;
  68. } else {
  69. cout << sprev << endl;
  70. }
  71. }
  72. count = 1;
  73. sprev = s0;
  74. }
  75. }
  76. }
  77. if (!(u && d)) {
  78. if (s0 != sprev) {
  79. if (u) {
  80. if (c) {
  81. cout << "1 " << s0 << endl;
  82. } else {
  83. cout << s0 << endl;
  84. }
  85. }
  86. if (!d && !u) {
  87. if (c) {
  88. cout << "1 " << s0 << endl;
  89. } else {
  90. cout << s0 << endl;
  91. }
  92. }
  93. } else {
  94. if (!d && !u) {
  95. if (c) {
  96. cout << count + 1 << " " << s0 << endl;
  97. } else {
  98. cout << s0 << endl;
  99. }
  100. }
  101. if (d) {
  102. if (c) {
  103. cout << count + 1 << " " << s0 << endl;
  104. } else {
  105. cout << s0 << endl;
  106. }
  107. }
  108. }
  109. }
  110. return 0;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement