Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- bool String_compare(char string_1[90900], char string_2[90900])
- {
- int i = 0;
- while (string_1[i] != '\0' && string_2[i] != '\0')
- {
- if (string_1[i] != string_2[i])
- return false;
- else
- i++;
- }
- return true;
- }
- int count_ways(char grid[30][30][101], int current_row, int current_column, char word_matrix[900][100], int word_count, int word_index)
- {
- if (!strcmp(grid[current_row][current_column], word_matrix[word_index]))
- {
- if (word_count == word_index)return 1;
- else return count_ways(grid, current_row + 1, current_column, word_matrix, word_count, word_index+1) +
- count_ways(grid, current_row - 1, current_column, word_matrix, word_count, word_index+1) +
- count_ways(grid, current_row, current_column + 1, word_matrix, word_count, word_index+1) +
- count_ways(grid, current_row, current_column - 1, word_matrix, word_count, word_index+1);
- }
- else return 0;
- }
- int countReads(char grid[30][30][101], int gridRows, int gridColumns, char sentence[90001])
- {
- char word_matrix[900][100];
- int index = 0;
- int i = 0;
- int j = 0;
- while (sentence[index] != '\0')
- {
- if (sentence[index] != ' ')
- {
- word_matrix[i][j] = sentence[index];
- j++;
- }
- else
- {
- word_matrix[i][j] = '\0';
- i++;
- j = 0;
- }
- index++;
- }
- int count = 0;
- for (int n = 0; n < gridRows; n++)
- {
- for (int m = 0; m < gridColumns; m++)
- {
- count += count_ways(grid, n, m, word_matrix, i, 0);
- }
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement