-
Notifications
You must be signed in to change notification settings - Fork 0
/
WSPS.c
71 lines (52 loc) · 1.57 KB
/
WSPS.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
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
/*
* Word Search Puzzle Solver
* Version: 1.0.1
* Author: Joie Angelo Llantero
* Author URL: https://joiellantero.codes
* Github: https://github.com/joiellantero/word-search-puzzle-solver
* Word Search Puzzle Solver Copyright (c) 2020 Joie Llantero
*/
#include<stdio.h>
#include<string.h>
#include"WSPS_lib.h"
int main (){
//sorting the words inn alphabetical (ascending) order
int num_words = 0;//the number of words to be entered by the user.
printf("Input n: ");
scanf("%d ", &num_words);
char words[num_words][16];//this is the words array
get_words(num_words, words);
//sorting words using heap sort (or bubble sort)
sort_words(num_words, words);
puts("\nSorted Words:");
print_words(num_words, words);
//searching for words
int m = 0;
printf("\nInput m: ");//the number of rows and columns for the board
scanf("%d", &m);
getchar();
//declaration of the board variable
char board[m][m];
//enter the characters in the board
populate_board(m, board);
//print the board
puts("\nBoard:");
print_board(m, board);
//now searching for the words in the board
int wp[num_words][2];//this is the word_positions array
int wd[num_words][2];//this is the word_directions array
for (int i = 0; i < num_words; i++){
for (int j = 0; j < 1; j++){
wd[i][j] = 5;
}
}
puts("");
search_words(m, board, num_words, words, wp, wd);
//print the found words
puts("Solutions:");
print_solutions(num_words, words, wp, wd);
//board modification
puts("\nModified Board: ");
edit_board(m, board, num_words, words, wp, wd);
return 0;
}