recursion

C# Recursion Depth - How Deep can you go

懵懂的女人 提交于 2020-01-18 15:48:51
问题 Is there any control how much you can Recursively call something? From a basic test program I get a recursion depth of just over 18k which depends on the stacksize.... is there a way to set up a chunk of memory (perhaps a thread) with a massive stack to increase recursion depth? 回答1: I've increased the stack size during some documents recognition. It was really needed. So you can increase stack size for thread using following code: var stackSize = 10000000; Thread thread = new Thread(new

PHP Generate every 2 character combo of the alphabet. Twist: duplicates letters allowed [closed]

五迷三道 提交于 2020-01-17 17:27:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I believe there is something like 67 million combination of two character strings using only the letters of the alphabet. I basically want an array in PHP containing something like the following Array ( [1] => AA [2] => AB [3] => AC [4] => AD [5] => AE [6] => AF [7] => AG [8] => AH [9] => AI [10] => AJ .... and

Difference between char array[100] and char *array when calling functions?

大城市里の小女人 提交于 2020-01-17 13:53:03
问题 i'd like to know why this code works fine with char tab[100] but doesn't work if I use char *tab ? fgets function takes a char* array as a parameter right ? #include <stdio.h> #include <stdlib.h> #include <string.h> Int Palindrome(char* str, int i, int j); int main() { char tab[100]; printf("Enter your string : \n"); fgets(tab, 100, stdin); int j = strlen(tab); printf("%d\n", Palindrome(tab, 0, j - 2)); return 0; } int Palindrome(char* str, int i, int j) { if (i >= j) { printf("My word is a

Difference between char array[100] and char *array when calling functions?

这一生的挚爱 提交于 2020-01-17 13:52:05
问题 i'd like to know why this code works fine with char tab[100] but doesn't work if I use char *tab ? fgets function takes a char* array as a parameter right ? #include <stdio.h> #include <stdlib.h> #include <string.h> Int Palindrome(char* str, int i, int j); int main() { char tab[100]; printf("Enter your string : \n"); fgets(tab, 100, stdin); int j = strlen(tab); printf("%d\n", Palindrome(tab, 0, j - 2)); return 0; } int Palindrome(char* str, int i, int j) { if (i >= j) { printf("My word is a

recursive make Q.: generic target *after* other targets?

走远了吗. 提交于 2020-01-17 12:13:22
问题 I know that recursive make is deemed evil, etc. Please bear with me anyway. We manage a relatively large project with GNU make, which heavily uses make includes to keep the individual make files simple. I'd like to add a target which gets executed after other targeted. More precisely, the problem is the following: I have a Makefile like this: PROJ_SRC = a.cpp b.cpp PROJ_LIB = ab PROJ_SUBDIRS = x/ y/ z/ PROJ_EXAMPLES = example/ I would like to first call make in the subdirs x,y,z, then build

How to call two functions and use their results as arguments for each other?

泄露秘密 提交于 2020-01-17 11:17:12
问题 I have code: let join a ~with':b ~by:key = let rec a' = link a ~to':b' ~by:key and b' = link b ~to':a' ~by:(Key.opposite key) in a' and compilation result for it is: Error: This kind of expression is not allowed as right-hand side of `let rec' build complete I can rewrite it to: let join a ~with':b ~by:key = let rec a'() = link a ~to':(b'()) ~by:key and b'() = link b ~to':(a'()) ~by:(Key.opposite key) in a'() It is compilable variant, but implemented function is infinitely recursive and it is

Compare directory name to string

放肆的年华 提交于 2020-01-17 08:36:29
问题 I've created this very simple batch file for the sake of testing a concept I'm hoping to utilize. I need to recursively delete all of one type of file except in folders with a specific name. Here's my code: :recur FOR /f %%a IN ('DIR /b') DO ( IF EXIST %%a\NUL ( IF ["%%a" NEQ "subtest2"] ( ECHO %%a CD %%a CALL :recur CD .. ) ) COPY "*.cfm" "*_copy.cfm" REM DEL "*_copy*.cfm" ) Right now I'm just testing using copy instead of delete. Basically, this should create a copy of all the .cfm files

StringIndexOutOfBounds when removing adjacent duplicate letters

我怕爱的太早我们不能终老 提交于 2020-01-17 07:53:49
问题 Here is my code: public static String removeAdjDuplicates(String s) { if(s == "" || s == null || s.isEmpty()) return s; if(s.length() < 2) return s; if(s.charAt(0) != s.charAt(1)) s = s.charAt(0) + removeAdjDuplicates(s.substring(1)); if(s.charAt(0) == s.charAt(1)) //line 37 return removeAdjDuplicates(s.substring(2)); return s; } With the input string "ull", I get the following error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1 at java

StringIndexOutOfBounds when removing adjacent duplicate letters

泪湿孤枕 提交于 2020-01-17 07:53:43
问题 Here is my code: public static String removeAdjDuplicates(String s) { if(s == "" || s == null || s.isEmpty()) return s; if(s.length() < 2) return s; if(s.charAt(0) != s.charAt(1)) s = s.charAt(0) + removeAdjDuplicates(s.substring(1)); if(s.charAt(0) == s.charAt(1)) //line 37 return removeAdjDuplicates(s.substring(2)); return s; } With the input string "ull", I get the following error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1 at java

Find all paths from one node to another in an undirected graph [adjacency list]

六月ゝ 毕业季﹏ 提交于 2020-01-17 05:51:06
问题 So I have a graph in the form of an adjacency list, structured as in the code below. Given this form of a data structure, I was wondering how it would be possible to go about finding and printing all the possible paths from a given node to another node. I'm aware I might have to used stacks to perform a DFS or queues to perform BFS, which I know how to do, but am confused by how to find all the possible paths typedef struct graph { int n, maxn; Vertex** vertices; }Graph; typedef struct vertex