-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqback.c
35 lines (33 loc) · 847 Bytes
/
qback.c
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
/*--------------------------------------------------------------*
* Find words also word when quarter reversed *
*--------------------------------------------------------------*/
#include "d2.h"
#include <stdio.h>
#include <string.h>
int main(void)
{
char qb[MAXLEN+1];
Dict d = Dict_open(NULL);
const char *word;
int len, i, q;
for (len=8; len<=MAXLEN; len+=4) {
int l4 = len/4;
Dscan ds = Dscan_open(d, len);
while ((word = Dscan_read(ds)) != NULL) {
for (q=0; q<4; q++) {
strcpy(qb, word);
for (i=0; i<l4; i++) {
qb[q*l4 + i] = word[q*l4 + l4-i-1];
}
if (strcmp(qb, word) != 0) { /* Ignore if trivial */
if (Dict_isword(d, qb, len)) {
printf("%s %s\n", word, qb);
}
}
}
}
Dscan_close(ds);
}
Dict_close(d);
return 0;
}