DS File
DS File
NEW DELHI
Data Structures
Session: 2023 – 27
PROJECT-BASED LEARNING
Crossword Puzzle Using Matrix
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <string>
return true;
}
return true;
}
void placeHorizontally(vector<vector<char>>& grid, const string& word,
int row, int col) {
for (int i = 0; i < word.length(); ++i) {
grid[row][col + i] = word[i];
}
}
if (horizontal) {
if (canPlaceHorizontally(grid, word, row, col)) {
placeHorizontally(grid, word, row, col);
placed = true;
}
} else {
if (canPlaceVertically(grid, word, row, col)) {
placeVertically(grid, word, row, col);
placed = true;
}
}
attempts++;
}
return placed;
}
int main() {
srand(time(0));
printCrossword(grid);
return 0;
}
OUTPUT