Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdio.h>
  3. void scob ( char *s, int n);
  4. int main ()
  5. {
  6. int n;
  7. char s[20];
  8. gets (s);
  9. scob (s,n);
  10. puts (s);
  11.  
  12. }
  13. void scob ( char *s, int n)
  14. {
  15. char *p, *q;
  16. int r;
  17. p=s;
  18. while (r!=0)
  19. {
  20. if ( *p < '0' || *p > '9')
  21. {
  22. q = strchr (p, '\0');
  23. while ( q != (p-1))
  24. {
  25. *(q+1)=*q;
  26. q--;
  27. }
  28. strncpy (p, "(", 1);
  29. while (*p < '0' || *p > '9' && *p!='\0')
  30. {
  31. p++;
  32. }
  33. if (*p=='\0')
  34. {
  35. *(p+1)=*p;
  36. strncpy (p, ")",1);
  37. r=0;
  38. }
  39. q = strchr (p, '\0');
  40. while (q != (p-1))
  41. {
  42. *(q+1)=*q;
  43. q--;
  44. }
  45. strncpy (p, ")",1);
  46. }
  47. p++;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement