aboutsummaryrefslogtreecommitdiff
path: root/Random/list_all_substrings.c
diff options
context:
space:
mode:
Diffstat (limited to 'Random/list_all_substrings.c')
-rw-r--r--Random/list_all_substrings.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Random/list_all_substrings.c b/Random/list_all_substrings.c
new file mode 100644
index 0000000..e51d1ea
--- /dev/null
+++ b/Random/list_all_substrings.c
@@ -0,0 +1,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);
+}