Advertisement
STANAANDREY

ex sim

Jan 23rd, 2023
753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <stdlib.h>
  4. #define NMAX 200
  5.  
  6. void del(char s[], int pos) {
  7.   for (int i = pos; s[i]; i++) {
  8.     s[i] = s[i + 1];
  9.   }
  10. }
  11.  
  12. int main(void) {
  13.   static char line[NMAX + 1];
  14.   if (fgets(line, NMAX + 1, stdin) == NULL) {
  15.     fprintf(stderr, "error!\n");
  16.     exit(-1);
  17.   }
  18.   for (int i = 1; line[i]; i++) {
  19.     int end = 0;
  20.     for (int j = i; !end && !isalpha(line[j]); j++) {
  21.       if (!line[j]) {
  22.     end = 1;
  23.       }
  24.     }
  25.     if (!end && !isalpha(line[i - 1]) && !isalpha(line[i])) {
  26.       del(line, i);
  27.       i--;
  28.     }
  29.   }
  30.   puts(line);
  31.   return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement