fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. #include <string>
  5. using namespace std;
  6.  
  7. void cuvMod(char rez[]){
  8. int nrLitere = strlen(rez);
  9. if(nrLitere % 2 == 0){
  10. for(int i = nrLitere / 2; rez[i] != '\0'; i++){
  11. cout << rez[i];
  12. }
  13. for(int i = 0; i < nrLitere / 2; i++){
  14. cout << rez[i];
  15. }
  16. }else if(nrLitere % 2 == 1){
  17. int x = nrLitere / 2;
  18. for(int i = nrLitere / 2 + 1; rez[i] != '\0'; i++){
  19. cout << rez[i];
  20. }
  21. cout << rez[x];
  22. for(int i = 0; i < nrLitere / 2; i++){
  23. cout << rez[i];
  24. }
  25. }
  26. }
  27.  
  28. int main(){
  29. ifstream fin("ex.txt");
  30. char chr[2000];
  31. char cpy[2000];
  32. strncpy(cpy, " ", 2000);
  33. int a = 0, z = 0;
  34.  
  35. while(cin.getline(chr, 2000)){
  36. //cout << chr << "\n";
  37. //cout << strlen(chr);
  38. for(int i = 0; i < strlen(chr); i++){
  39. //cout << chr[i];
  40. //cout << i << "\n";
  41. a++;
  42. if(!isalpha(chr[i]) || i == strlen(chr) - 1){
  43. a--;
  44. if(i == strlen(chr) - 1){
  45. a++;
  46. }
  47. if(a != 0){
  48. //cout << z << "\n";
  49. //cout << a << "\n";
  50. strncpy(cpy, chr+z, a);
  51. //cout << cpy << "\n";
  52. cuvMod(cpy);
  53. strncpy(cpy, " ", 2000);
  54. }
  55. if(i != strlen(chr) - 1){
  56. cout << chr[i];
  57. z = i+1;
  58. a = 0;
  59. }
  60. }
  61. }
  62. z = 0;
  63. a = 0;
  64. cout << "\n";
  65. }
  66.  
  67. return 0;
  68. }
  69.  
Success #stdin #stdout 0s 4496KB
stdin
Ana, dar si Maria invata sa programeze pe WellCode!!
test
Invata si tu sa programezi$$
stdout
anA, rad is iarMa atainv as amezeprogr ep CodeWell!!
stte
ataInv is ut as ameziprogr$$