summaryrefslogtreecommitdiff
path: root/I_anno/Programmazione_1/ex2_06_12_18.cc
blob: 50744ba83bd9d219b2a031c5c74016b9d2c9b7e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<iostream>
#define N 3
#define M 4

using namespace std;

bool* func(string (*A)[M], short k, string s) {
    bool* arr = new bool[N];

    for(int i = 0; i < N; ++i) {
        short counter{};
        for(int j = 0; j < M; ++j) {
            if(A[i][j].find(s) != std::string::npos)
                ++counter;
        }

        arr[i] = (counter >= k);
    }
    
    return arr;
}

int main() {
    string Arr[N][M] = {
        {"Ciaone", "Come one va?", "We one", ""},
        {"Ciaoe", "Come va?", "We one", ""},
        {"Ciaone", "Come one va?", "We one", ""},
    };

    bool* v = func(Arr, 2, "one");
    for(int i = 0; i < N; ++i) cout << v[i] << ' ';

    return 0;
}