recursion

How can I query all Childcontrols of a Winform recursively? [duplicate]

余生颓废 提交于 2020-01-09 11:45:10
问题 This question already has answers here : How can I get all controls from a Form Including controls in any container? (4 answers) Closed 4 years ago . Iam using windows forms. How can I query all child controls of a Form recursively which have a certain type? In SQL you would use a selfjoin to perform this. var result = from this join this ???? where ctrl is TextBox || ctrl is Checkbox select ctrl; Can I also do this in LINQ? EDIT: LINQ supports joins. Why can't I use some kind of selfjoin?

How can I query all Childcontrols of a Winform recursively? [duplicate]

两盒软妹~` 提交于 2020-01-09 11:43:13
问题 This question already has answers here : How can I get all controls from a Form Including controls in any container? (4 answers) Closed 4 years ago . Iam using windows forms. How can I query all child controls of a Form recursively which have a certain type? In SQL you would use a selfjoin to perform this. var result = from this join this ???? where ctrl is TextBox || ctrl is Checkbox select ctrl; Can I also do this in LINQ? EDIT: LINQ supports joins. Why can't I use some kind of selfjoin?

Find the highest subset of an integer array whose sums add up to a given target

馋奶兔 提交于 2020-01-09 11:33:06
问题 I am trying to find a subset of values within an array which add up to a given number and return an array of that subset. I need the return array to contain the highest possible largest value. The integer array will always be in ascending order but there will not always be a valid answer. If there is no valid answer I need to return a string along the lines of 'No valid answer'. For example: If the int array is: [1, 2, 3, 5, 7, 9, 11] and the target is 19 - I want the return array to be [1, 7

Find the highest subset of an integer array whose sums add up to a given target

自古美人都是妖i 提交于 2020-01-09 11:31:57
问题 I am trying to find a subset of values within an array which add up to a given number and return an array of that subset. I need the return array to contain the highest possible largest value. The integer array will always be in ascending order but there will not always be a valid answer. If there is no valid answer I need to return a string along the lines of 'No valid answer'. For example: If the int array is: [1, 2, 3, 5, 7, 9, 11] and the target is 19 - I want the return array to be [1, 7

Turning a recursive function into a for loop?

亡梦爱人 提交于 2020-01-09 11:23:59
问题 Does every recursive function have an equivalent for loop? (Both achieve the same result). I have this recursive function: private static boolean recur(String word, int length) { if(length == 1 || length == 2) return false; if(length == 0) return true; if(words[length].contains(word.substring(0, length))) return recur(word.substring(length), word.length() - length); return recur(word, length-1); } Given that words is a Set[], and where words[i] = a set with words of length i. What am trying

Turning a recursive function into a for loop?

对着背影说爱祢 提交于 2020-01-09 11:23:25
问题 Does every recursive function have an equivalent for loop? (Both achieve the same result). I have this recursive function: private static boolean recur(String word, int length) { if(length == 1 || length == 2) return false; if(length == 0) return true; if(words[length].contains(word.substring(0, length))) return recur(word.substring(length), word.length() - length); return recur(word, length-1); } Given that words is a Set[], and where words[i] = a set with words of length i. What am trying

How to find all IDs of children recursively?

陌路散爱 提交于 2020-01-09 06:56:26
问题 I would like to get all IDs from children in a tree with MySQL only. I have a table like this: ID parent_id name 1 0 cat1 2 1 subcat1 3 2 sub-subcat1 4 2 sub-subcat2 5 0 cat2 Now I'm trying to get all child IDs for cat1 (2,3,4) recursively. Is there any way how to achieve that? 回答1: There are two basic methods for doing this: adjacency lists and nested lists. Take a look at Managing Hierarchical Data in MySQL. What you have is an adjacency list. No there isn't a way of recursively grabbing

Iterate over a deeply nested level of hashes in Ruby

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-09 06:20:53
问题 So I have a hash, and for each level of the hash, I want to store its key and value. The problem is, a value can be another hash array. Furthermore, that hash can contain key value pairs where the value is again another hash array, etc, etc. Also, I won't know how deeply nested each hash will be. To give an example: { :key1 => 'value1', :key2 => 'value2', :key3 => { :key4 => 'value4', :key5 => 'value5' }, :key6 => { :key7 => 'value7', :key8 => { :key9 => 'value9' } } } ..And so on. What I

2D MATRIX statement for 5 x 5 Grid

删除回忆录丶 提交于 2020-01-07 09:30:33
问题 Given a 5 x 5 Grid comprising of tiles numbered from 1 to 25 and a set of 5 start-end point pairs. For each pair,find a path from the start point to the end point. The paths should meet the below conditions: a) Only Horizontal and Vertical moves allowed. b) No two paths should overlap. c) Paths should cover the entire grid Input consist of 5 lines. Each line contains two space-separated integers,Starting and Ending point. Output: Print 5 lines. Each line consisting of space-separated integers

2D MATRIX statement for 5 x 5 Grid

二次信任 提交于 2020-01-07 09:30:14
问题 Given a 5 x 5 Grid comprising of tiles numbered from 1 to 25 and a set of 5 start-end point pairs. For each pair,find a path from the start point to the end point. The paths should meet the below conditions: a) Only Horizontal and Vertical moves allowed. b) No two paths should overlap. c) Paths should cover the entire grid Input consist of 5 lines. Each line contains two space-separated integers,Starting and Ending point. Output: Print 5 lines. Each line consisting of space-separated integers