#include #include #include #include #include #include using namespace std; struct dotplot { dotplot(const string & A, const string & B, int w, int k); void print(ostream& is); private: vector > matrix; }; int main() { ifstream input("input.txt"); if (!input.good()) { cerr << "Hey! Where's the input file?\n"; exit(1); } string A, B; int w, k; input >> A >> B >> w >> k; dotplot dp(A, B, w, k); dp.print(cout); return 0; } dotplot::dotplot(const string & A, const string & B, int w, int k) { int i, j, l; int count = 0; int m = A.length(); int n = B.length(); matrix.resize(m - w + 1); for (i=0; i < m - w + 1; ++i) { matrix[i].resize(n - w + 1); } for (i=0; i < m - w + 1; ++i) { for (j=0; j < n - w + 1; ++j) { count = 0; for (l=0; l < w; ++l) { if (A[i + l] == B[j + l]) ++count; } matrix[i][j] = (count >= k ? 1 : 0); } } } void dotplot::print(ostream& is) { int i, j; for (i=0; i < matrix.size(); ++i) { for (j=0; j < matrix[i].size(); ++j) { is << matrix[i][j] << " "; } is << endl; } }