fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. string s;
  8. char a[32][24];
  9. int b[32];
  10. int i = 0;
  11. int j = 0;
  12.  
  13.  
  14. //ЧТЕНИЕ ВВЕДЁННОЙ СТРОКИ
  15. getline (cin, s);
  16.  
  17. for (int i = 0; i < 32; i++) {
  18. for (int j = 0; j < 24; j++)
  19. a[i][j] = '*';
  20. b[i] = 0;
  21. }
  22.  
  23. int x = 0;
  24. int y = 0;
  25.  
  26. //РАЗДЕЛЕНИЕ СТРОКИ НА СЛОВА
  27. for (int i = 0; i < s.length()-1; i++) {
  28. if (s[i] != ' ') {
  29. a[x][y] = s[i];
  30. y += 1;
  31. }
  32. else {
  33. x += 1;
  34. y = 0;
  35. }
  36. }
  37.  
  38. int low = 0;
  39. int high = 0;
  40.  
  41. //ОПРЕДЕЛЕНИЕ РЕГИСТРА
  42. for (i = 0; i < 32; i++) {
  43. if (a[i][0] == '*')
  44. break;
  45. for (j = 0; j < 23; j++) {
  46. if (a[i][j] == '*')
  47. break;
  48.  
  49. if ((int) a[i][j] > 96 && (int) a[i][j] < 123)
  50. low += 1;
  51.  
  52. if ((int) a[i][j] > 64 && (int) a[i][j] < 91)
  53. high += 1;
  54. }
  55. if (low != 0 && high == 0) {
  56. a[i][j] = ' ';
  57. b[i] = 1;
  58. }
  59. else if (high != 0 && low == 0) {
  60. a[i][j] = ' ';
  61. b[i] = 2;
  62. }
  63. else {
  64. a[i][j] = ' ';
  65. b[i] = -1;
  66. }
  67. low = 0;
  68. high = 0;
  69. }
  70.  
  71. int n = i;
  72. j = 0;
  73.  
  74. //ВЫВОД ИЗМЕНЁННЫХ СЛОВ
  75. for (int i = 0; i < n; i++) {
  76. switch (b[i]) {
  77. case 1:
  78. while (a[i][j] != '*') {
  79. if ((int) a[i][j] > 96 && (int) a[i][j] < 123)
  80. cout << (char) ((int) a[i][j] - 32);
  81. else cout << a[i][j];
  82. j++;
  83. }
  84. break;
  85. case 2:
  86. while (a[i][j] != '*') {
  87. if ((int) a[i][j] > 64 && (int) a[i][j] < 91)
  88. cout << (char) ((int) a[i][j] + 32);
  89. else cout << a[i][j];
  90. j++;
  91. }
  92. break;
  93. }
  94. j = 0;
  95. }
  96.  
  97. j = 0;
  98.  
  99. //ВЫВОД ОСТАВШИХСЯ СЛОВ
  100. for (int i = 0; i < n; i++) {
  101. if (b[i] == -1)
  102. while (a[i][j] != '*') {
  103. cout << a[i][j];
  104. j += 1;
  105. }
  106. j = 0;
  107. }
  108.  
  109. return 0;
  110. }
Success #stdin #stdout 0s 3476KB
stdin
fbjkvh fbjknD flbk DGNBNCV fdbv-sdv sfbknj, FDGBV
stdout
FBJKVH FLBK dgnbncv FDBV-SDV SFBKNJ, fdgb fbjknD