-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAB-backracking-ndamen.html
228 lines (211 loc) · 4.74 KB
/
AB-backracking-ndamen.html
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<!DOCTYPE html>
<html lang="de">
<head>
<title>Visualisierung von Algorithmen: N Damen</title>
<meta http-equiv="Content-Type" content="text/html" charset= "utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
</head>
<body class="w3-container">
<header class="w3-container w3-blue w3-round-large w3-card-4">
<h1>Visualisierung von Algorithmen: N Damen</h1>
</header>
<p>by NAME ... (2015)</p>
<div class="w3-card-4" style="width:64px">
<img id="dame" src="./assets/img/dame.jpg" alt="dame">
</div>
<p>First click start to handle animation</p>
<form>
<div class="w3-input-group">
<input id="input_slow" type="number" value="50" min="0" max="5000" placeholder="5" maxlength="3" size="3">
<label>Verzögerung</label>
<input type="button" class="w3-btn w3-blue w3-round-large" value="start" onclick="start_ndamen();" />
</form>
<p id="duration">
elapsed time ...
</p>
<p>
<canvas id="canvas" width="512" height="512" class="w3-round-large w3-card-4" style="background-color:blue"></canvas>
</p>
<p>
See also:
<ul class="w3-ul w3-card-4">
<li>
<a href="http://www.w3schools.com/w3css/default.asp">http://www.w3schools.com/w3css/default.asp</a>
</li>
<li>
<a href="http://www.w3schools.com/js/default.asp">http://www.w3schools.com/js/default.asp</a>
</li>
</ul>
</p>
<footer class="w3-container w3-blue w3-round-large w3-card-4">
<p>NAME .... (2015)</p>
</footer>
<script language="javascript" type="text/javascript" src="./assets/js/place.js"></script>
<script language="javascript" type="text/javascript" src="./assets/js/worker_ndamen.js"></script>
</body>
</html>
<!-- /*
//============================================================================
//Name : BackTracking-DAMEN.c
//Author : hofa
//Version :
//Copyright : open source
//Description : Hello World in C, Ansi-style
//============================================================================
//
//AUFGABE: 8 DAMEN PROBLEM
//Gesucht ist die Konfiguration von 8 Damen auf einem 8x8 Schachbrett,
//sodass keine Dame eine andere bedroht.
//
//
//PAP:
//void BT(int i) // 1...8 : i-te Dame
// int k;
//
// for(k=1..8)
// if (feld[i][k] nicht bedroht)
// Setze feld[i][k] besetzt
//
// if(Brett ist voll)
// Gib Lösung aus
// else
// BT(i+1)
//
// Nimm dame vom feld[i][k]
//
//
//#include <stdio.h>
//#include <stdlib.h>
//
//#define DIM 8
//#define EMPTY '.'
//#define NOTEMPTY '#'
//
//char a[DIM][DIM];
//
//
//void init(void);
//void display(void);
//int isInDanger(int i, int j);
//
//void BT(int i);
//
//
//int main(void) {
// puts("8 Damen: Backtracking"); /* prints 03-c-grundlagen */
//
// init();
//
// BT(0);
//
// return EXIT_SUCCESS;
//}
//
//
//void BT(int i){ // i-th Dame
// int k;
//
// for (k = 0; k < DIM; ++k) {
// if(! isInDanger(i,k)){
// a[i][k]= NOTEMPTY;
//
// if (i == DIM-1){ // we got done
// display();exit(0);
// }else{
// BT(i+1); // try next step
// }
//
// a[i][k]= EMPTY; // backtrack
// }
// }
//}
//
//void init (void){
// int i,j;
//
// for (i = 0; i < DIM; ++i) {
// for (j = 0; j < DIM; ++j) {
// a[i][j]=EMPTY;
// }
// }
//}
//
//void display (void){
// int i,j;
//
// for (i = 0; i < DIM; ++i) {
// for (j = 0; j < DIM; ++j) {
// printf("%c ", a[i][j]);
// }
// printf("\n");
// }
//}
//
//
//int isInDanger(int i, int j){
// int ret;
// int col,row;
// int iorig, jorig;
//
// iorig=i;
// jorig=j;
//
// ret=0; // assume to be not in danger
// // check row
// for (col = 0; col < DIM; ++col) {
// if(a[i][col]==NOTEMPTY){
// return 1;
// }
// }
//
// // check col
// for (row = 0; row < DIM; ++row) {
// if(a[row][j]==NOTEMPTY){
// return 1;
// }
// }
//
// // diag "/"
// // --
// while (i >= 0 && j < DIM){
// if(a[i][j]== NOTEMPTY)
// return 1;
// else
// i--; j++; // right and up
// }
//
// // ++
// i=iorig; j= jorig;
// while (i< DIM && j >= 0){
// if(a[i][j]== NOTEMPTY)
// return 1;
// else
// i++; j--; // left and down
// }
//
// // diag "\\"
// //
// i=iorig; j= jorig;
// while (i>= 0 && j >= 0){
// if(a[i][j]== NOTEMPTY)
// return 1;
// else
// i--; j--; // left and up
// }
//
//
// //
// i=iorig; j= jorig;
// while (i<DIM && j < DIM){
// if(a[i][j]== NOTEMPTY)
// return 1;
// else
// i++; j++; // right and down
// }
//
//display();
//printf("\nnicht gefaehrdet ist: i=%i,j=%i\n", iorig,jorig);
//getchar();
// return 0;
//} -->