From 033867165ee1398d5d94f265754534edc2a2a394 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 6 Mar 2023 01:32:31 -0300 Subject: Mais coisas aleatorias --- Random/list_all_substrings.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Random/list_all_substrings.c (limited to 'Random/list_all_substrings.c') 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 +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); +} -- cgit v1.2.3