fork download
  1. #include <iostream>
  2. #include <string.h>
  3. #include <cstring>
  4. #include <string>
  5. using namespace std;
  6.  
  7. const int MAX_LEN = 2000;
  8.  
  9. int este_litera(char c) {
  10. if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')) {
  11. return 1;
  12. }
  13. return 0;
  14. }
  15.  
  16. char cuv[MAX_LEN];
  17.  
  18. int main() {
  19. char s[MAX_LEN];
  20. int am_cuvant = 0;
  21. while (cin.getline(s, MAX_LEN)) {
  22. int len = strlen(s);
  23. if (len == 0) {
  24. cout << "\n" << "\n";
  25. }
  26. cuv[0] = '\0';
  27. int j = -1;
  28. for (int i = 0; i < len; ++i) {
  29. if (este_litera(s[i])) {
  30. ++j;
  31. cuv[j] = s[i];
  32. am_cuvant = 1;
  33. } else {
  34. ++j;
  35. cuv[j] = '\0';
  36. if (am_cuvant == 1) {
  37. for (int k = 0; k < j / 2; ++k) {
  38. char aux = cuv[k];
  39. cuv[k] = cuv[j / 2 + k + j % 2];
  40. cuv[j / 2 + k + j % 2] = aux;
  41. }
  42. cout << cuv;
  43. }
  44. cout << s[i];
  45. cuv[0] = '\0';
  46. j = -1;
  47. am_cuvant = 0;
  48. }
  49. }
  50. ++j;
  51. cuv[j] = '\0';
  52. if (am_cuvant == 1) {
  53. for (int k = 0; k < j / 2; ++k) {
  54. char aux = cuv[k];
  55. cuv[k] = cuv[j / 2 + k + j % 2];
  56. cuv[j / 2 + k + j % 2] = aux;
  57. }
  58. cout << cuv;
  59. }
  60. }
  61. return 0;
  62. }
  63.  
Success #stdin #stdout 0s 5552KB
stdin
anA, rad is iarMa atainv as amezeprogr ep CodeWell!!

ataInv is ut as ameziprogr$$ 
stdout
Ana, dar si Maria invata sa programeze pe WellCode!!

Invata si tu sa programezi$$