Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <cstring>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7.  
  8. using namespace std;
  9.  
  10. bool search(vector< vector<char> > &test, char *word, int x, int y){
  11.    
  12.     bool answer = false;
  13.     if(strlen(word)  > (test.size()-y)){
  14.         return false;  
  15.     }
  16.     else{
  17.         for(int i = 0; i < strlen(word); i++){
  18.             if(word[i] == test[x][y + i])
  19.         answer = true;
  20.             else
  21.         answer = false;
  22.             break;
  23.         }
  24.     }
  25.     return answer;
  26. }
  27.  
  28.  
  29. int main(int argc, char *argv[]){
  30.   int x, y;
  31.   string word;
  32.  
  33.   cin >> x;
  34.   cin >> y;
  35.  
  36.   vector< vector<char> > test;
  37.   test.resize(10);
  38.   for(int i = 0; i < test.size(); i++){
  39.     test[i].resize(y);
  40.   }
  41.  
  42.  
  43.    for (int i = 0; i < x; i++) {
  44.       for (int j = 0; j<y ; j++){
  45.     cin >> test[i][j];
  46.     }
  47.     }
  48.   for(int i = 0; i < x; i++) {
  49.       for(int j = 0; j < y; j++){
  50.     cout <<  test[i][j] << " ";
  51.     }
  52.       cout << endl;
  53.     }
  54.    
  55.     cin >> word;
  56.        
  57.     cout << word;
  58.    
  59.    
  60.    
  61.    
  62.   bool hatesearch = search(test, argv[1], atoi(argv[2]), atoi(argv[3]));
  63.  
  64.   if(hatesearch){
  65.       cout << "true" << endl;
  66.   }
  67.   else{
  68.       cout << "false" << endl;
  69.   }
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement