.
[ Voor 99% gewijzigd door SaphuA op 01-02-2022 16:27 ]
[ Voor 99% gewijzigd door SaphuA op 01-02-2022 16:27 ]
1
2
3
4
5
6
7
| int i = 0; while(true) { // bruteforce is je method; deze retouneert de nieuwe waarde die moet worden getest i = bruteforce(i); if( i == 0) break; } |
[ Voor 177% gewijzigd door SaphuA op 01-02-2022 16:27 ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| //origineel object recursieve_functie(object arg) { object newarg = foo(arg); //doe iets met arg if(newarg != null) //of een andere conditie om recursie te stoppen { return recursieve_functie(newarg); } } //omschrijven object niet_recursieve_functie(object arg) { //1) maak je argumenten locals object local_arg = arg; do { //2) overschrijf je locals elke iteratie localarg = foo(localarg); } while(localarg != null); //de conditie om recursie te stoppen return localarg; } |
-niks-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| // recursieve variant void OutputFiles(string path) { foreach(File f in GetFiles(path)) { if (f.IsDirectory()) OutputFiles(f.GetPath()) else Console.WriteLine(f.GetName()); } } // niet-recursieve variant void OutputFiles(string path) { Stack<string> paths = new Stack<string>(); paths.Push(path); while(paths.Count > 0) { path = paths.Pop(); foreach(File f in GetFiles(path)) { if (f.IsDirectory()) paths.Push(f.GetPath()); else Console.WriteLine(f.GetName()); } } } |
[ Voor 9% gewijzigd door .oisyn op 03-02-2011 15:04 ]
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.
Apple iPhone 16e LG OLED evo G5 Google Pixel 10 Samsung Galaxy S25 Star Wars: Outlaws Nintendo Switch 2 Apple AirPods Pro (2e generatie) Sony PlayStation 5 Pro
Tweakers is onderdeel van
DPG Media B.V.
Alle rechten voorbehouden - Auteursrecht © 1998 - 2025
•
Hosting door TrueFullstaq