Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cstring>
- #include <stdio.h>
- #include <stdlib.h>
- using namespace std;
- bool checkRight(vector < vector<char> > &matrix, char *word) {
- bool result = false;
- int counter = 0;
- /*if (strlen(word) > (matrix.size()-y)) {
- return false;
- }*/
- for(int i = 0; i < matrix.size(); i++){
- for(int j = 0; j < matrix.size(); j++){
- if((word[counter] == matrix[i][j + 1]) && (counter < strlen(word))) {
- result = true;
- counter++;
- break;
- }
- else{
- result = false;
- }
- }
- return result;
- }
- }
- bool checkLeft(vector < vector<char> > &matrix, char *word) {
- bool result = false;
- /*if (strlen(word) > (matrix.size()-y)) {
- return false;
- }*/
- for(int i = 0; i < matrix.size(); i++){
- for(int j = 0; j < matrix[i].size(); j++)
- if(word[0] == matrix[i][j - 1])
- result = true;
- else
- result = false;
- }
- return result;
- }
- bool checkDown(vector < vector<char> > &matrix, char *word) {
- bool result = false;
- /*if (strlen(word) > (matrix.size()-y)) {
- return false;
- }*/
- for(int i = 0; i < matrix.size(); i++){
- for(int j = 0; j < matrix[i].size(); j++)
- if(word[0] == matrix[i + 1][j])
- result = true;
- else
- result = false;
- }
- return result;
- }
- bool checkDiagRightUp(vector < vector<char> > &matrix, char *word) {
- bool result = false;
- /*if (strlen(word) > (matrix.size()-y)) {
- return false;
- }*/
- for(int i = 0; i < matrix.size(); i++){
- for(int j = 0; j < matrix[i].size(); j++)
- if(word[0] == matrix[i - 1][j + 1])
- result = true;
- else
- result = false;
- }
- return result;
- }
- bool checkDiagRightDown(vector < vector<char> > &matrix, char *word) {
- bool result = false;
- /*if (strlen(word) > (matrix.size()-y)) {
- return false;
- }*/
- for(int i = 0; i < matrix.size(); i++){
- for(int j = 0; j < matrix[i].size(); j++)
- if(word[0] == matrix[i + 1][j + 1])
- result = true;
- else
- result = false;
- }
- return result;
- }
- bool checkDiagLeftUp(vector < vector<char> > &matrix, char *word) {
- bool result = false;
- /*if (strlen(word) > (matrix.size()-y)) {
- return false;
- }*/
- for(int i = 0; i < matrix.size(); i++){
- for(int j = 0; j < matrix[i].size(); j++)
- if(word[0] == matrix[i - 1][j - 1])
- result = true;
- else
- result = false;
- }
- return result;
- }
- bool checkDiagLeftDown(vector < vector<char> > &matrix, char *word) {
- bool result = false;
- /*if (strlen(word) > (matrix.size()-y)) {
- return false;
- }*/
- for(int i = 0; i < matrix.size(); i++){
- for(int j = 0; j < matrix[i].size(); j++)
- if(word[0] == matrix[i + 1][j - 1])
- result = true;
- else
- result = false;
- }
- return result;
- }
- bool checkUp(vector < vector<char> > &matrix, char *word) {
- bool result = false;
- /*if (strlen(word) > (matrix.size()-y)) {
- return false;
- }*/
- for(int i = 0; i < matrix.size(); i++){
- for(int j = 0; j < matrix[i].size(); j++)
- if(word[0] == matrix[i-1][j])
- result = true;
- else
- result = false;
- }
- return result;
- }
- int main(int argc, char *argv[]) {
- int x;
- int y;
- cin >> x;
- cin >> y;
- vector< vector<char> > matrix;
- matrix.resize(x);
- for(int i = 0; i < matrix.size(); i++)
- matrix[i].resize(y);
- for (int i = 0; i < x; i++)
- for (int j = 0; j < y; j++)
- cin >> matrix[i][j];
- for (int i = 0; i < x; i++) {
- for (int j = 0; j < y; j++)
- cout << matrix[i][j] << " ";
- cout << endl;
- }
- bool isCheckRight = checkRight(matrix, argv[1]);
- /*bool isCheckUp = checkUp(matrix, argv[1]);
- bool isCheckLeft = checkLeft(matrix, argv[1]);
- bool isCheckDown = checkDown(matrix, argv[1]);
- bool isCheckDiagRightUp = checkDiagRightUp(matrix, argv[1]);
- bool isCheckDiagRightDown = checkDiagRightDown(matrix, argv[1]);
- bool isCheckDiagLeftUp = checkDiagLeftUp(matrix, argv[1]);
- bool isCheckDiagLeftDown = checkDiagLeftDown(matrix, argv[1]);*/
- if (isCheckRight) {
- cout << "true" << endl;
- }
- else{
- cout << "false" << endl;
- }
- /*if (isCheckUp) {
- cout << "true" << endl;
- }
- else{
- cout << "false" << endl;
- }
- if (isCheckLeft) {
- cout << "true" << endl;
- }
- else{
- cout << "false" << endl;
- }
- if (isCheckDown) {
- cout << "true" << endl;
- }
- else{
- cout << "false" << endl;
- }
- if (isCheckDiagRightUp) {
- cout << "true" << endl;
- }
- else{
- cout << "false" << endl;
- }
- if (isCheckDiagRightDown) {
- cout << "true" << endl;
- }
- else{
- cout << "false" << endl;
- }
- if (isCheckDiagLeftUp) {
- cout << "true" << endl;
- }
- else{
- cout << "false" << endl;
- }
- if (isCheckDiagLeftDown) {
- cout << "true" << endl;
- }
- else{
- cout << "false" << endl;
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement