Advertisement
dmitryokh

Untitled

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