Advertisement
Znta777

Untitled

Nov 29th, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. char SpaceKill(char* str, int i ) {
  5. int n = strlen(str) - 1;
  6. int j;
  7. if (str[i]==' ' && str[i+1]==' ') {
  8. SpaceKill(str, i + 1);
  9. }
  10. if (str[i]=="." && str[i+1]== " ") {
  11. SpaceKill(str, i + 1);
  12. }
  13. if (str[i]=="'" && str[i + 1]== "'" ) {
  14. SpaceKill(str, i + 1 );
  15. }
  16. if (str[i]=="(" && str[i + 1]== ")" ) {
  17. SpaceKill(str, i + 1 );
  18. }
  19. for (j = i; j < n; j++)
  20. {
  21. str[j]=str[j + 1];
  22. }
  23. str[j] = 0;
  24. }
  25. int main() {
  26.  
  27. //5 задание
  28. char str[228];
  29. int i;
  30. printf("Введите строку: ");
  31. gets (str);
  32. int n = strlen(str);
  33. for ( i = 0 ; i < n ;++i) {
  34. if (str[i] ==' ' && str[i+1] == ' ') {
  35. SpaceKill(str, i + 1 );
  36. }
  37. }
  38. printf("%s", str);
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement