~cpp #include <stdio.h> #include <string.h> #include <stdlib.h> void swap2 (char *p, char *q) { char temp; temp = *p; *p = *q; *q = temp; } void main() { char string[200]; int numberOfString; char broker; FILE *before, *after; before = fopen("source.txt", "r"); fgets(string, 200, before); fclose(before); printf("%s\n",string); numberOfString = strlen(string); for (int i = 0; i < numberOfString; i++) { if (string[i] < 0 && string[i+ 1] < 0) { swap2(&string[i],&string[i+1]); i++; } } if(numberOfString%2==0) { int i; for(i=1;i<numberOfString/2+1;i++) { broker = string[numberOfString-i]; string[numberOfString-i] = string[i-1]; string[i-1] = broker; } } else { int i; for(i=1;i<numberOfString/2+2;i++) { broker = string[numberOfString-i]; string[numberOfString-i] = string[i-1]; string[i-1] = broker; } } printf("%s\n",string); after = fopen("result.txt", "w"); fputs(string, after); fclose(after); }