Advertisement
STANAANDREY

bacT9 sIII 2

May 25th, 2021
933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. #define NMAX 22
  5. char s[NMAX][NMAX];
  6.  
  7. int main() {
  8.     int n;
  9.     cin >> n;
  10.     for (int i = 1; i <= n; i++) {
  11.         cin >> s[i];
  12.     }
  13.     int prefLen = strlen(s[n]);
  14.     bool e = false;
  15.     for (int i = 1; i < n; i++) {
  16.         if (!strncmp(s[i], s[n], prefLen)) {
  17.             e = true;
  18.             cout << s[i] << ' ';
  19.         }
  20.     }
  21.     if (!e) {
  22.         cout << "nu exista" << endl;
  23.     }
  24.     return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement