Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- void func(char *str)
- {
- static int len = (int)strlen(str) - 2;
- static char new_str[128];
- static int counter = 0;
- if (len > 0)
- {
- new_str[counter] = *str;
- new_str[counter + 1] = '(';
- counter++;
- len -= 2;
- }
- else if (len < 0 && str[1])
- {
- new_str[counter] = *str;
- new_str[counter + 1] = ')';
- counter++;
- }
- else
- {
- new_str[counter] = *str;
- len--;
- }
- counter++;
- str++;
- if (*str)
- func(str);
- else std::cout << new_str << std::endl;
- }
- int main()
- {
- func("card");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement