aboutsummaryrefslogtreecommitdiff
path: root/Random/list_all_substrings.c
blob: e51d1eac6a890eaba4b7950b31268fe8558bd110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
int count = 0;
void resp(char *s, int i, int n){
	printf("\n");
	if(s[n+1] == '\0' && i <= n){
		for(int j=i; j <= n; ++j){
			printf("%c", s[j]);
		}
	count++;
		resp(s, 0, n-i-1);
	}else if(i <= n){
		for(int j=i; j <= n; ++j){
			printf("%c", s[j]);
		}
	count++;
		resp(s, i+1, n+1);
	}
	return;
}

int main(){
	resp("ABCDEFG", 0, 6);
	printf("%d\n", count);
}