aboutsummaryrefslogtreecommitdiff
path: root/Random/list_all_substrings.c
diff options
context:
space:
mode:
authorleo <leo@azuminha.com>2023-03-06 01:32:31 -0300
committerleo <leo@azuminha.com>2023-03-06 01:32:31 -0300
commit033867165ee1398d5d94f265754534edc2a2a394 (patch)
treeb44aae61efa7dca262655d593026635c8cd7c43e /Random/list_all_substrings.c
parentacadd0b6cd11d384e66302a66df8d4edb6a0e862 (diff)
Mais coisas aleatoriasHEADmaster
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);
+}