Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- void rm(char *code, int n){
- char *buf;
- if(n == 0){
- printf("%s\n", code);
- return;
- }
- buf = malloc(strlen(code)+2);
- strcpy(buf, code);
- strcat(buf, ".");
- rm(buf, n-1);
- if(n >= 2){
- strcpy(buf, code);
- strcat(buf, "-");
- rm(buf, n-2);
- }
- free(buf);
- }
- int main(int argc, char *argv[]){
- int len;
- if(argc != 2){
- printf("usage: %s n\n", argv[0]);
- return 1;
- }
- len = atoi(argv[1]);
- if(len <= 0){
- printf("n must be integer >= 1\n");
- return 1;
- }
- rm("", len);
- return 0;
- }
Add Comment
Please, Sign In to add comment