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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
//------------- First class for matrice letters -------------------------------
/** class for matrice letters
class Raides
{
private:
char raide; // matrice letter
public:
Raides(char Raide = ' '): raide(Raide) {}
~Raides() {}
void Deti(char Raide)
{
raide = Raide;
}
char ImtiRaide() {return raide;}
};
//------------------------- class for looking words -------------------------
#pragma once
#include <string>
using namespace std;
class Ieskoma
{
private:
string zodis; // ieskomas zodis
int x; // pozicija eiluteje
int y; // pozicija stulpelyje
public:
Ieskoma(): zodis(""), x(0), y(0) {}
~Ieskoma(){}
void Deti(string Zodis, int X, int Y)
{
zodis = Zodis;
x = X;
y = Y;
}
string ImtiZodi() {return zodis;}
int ImtiX() {return x;}
int ImtiY() {return y;}
};
//------------ conteiner class ----------------------------------
#include "Raides.h"
using namespace std;
/** class for crossword
class Kryziazodis
{
public:
static const int Ceil = 100; // max number of lines
static const int Cstulp = 100; // max number of columns
private:
Raides R[Ceil][Cstulp];
int n; // lines number
int m; // columns number
public:
Kryziazodis(int N = 0, int M = 0): n(N), m(M){}
~Kryziazodis(){}
int ImtiN() {return n;}
int ImtiM() {return m;}
void DetiN(int N) {n = N;}
void DetiM(int M) {m = M;}
void Deti(int i, int j, Raides r) {R[i][j] = r;}
Raides Imti(int i, int j) {return R[i][j];}
};
//--------------------------------- main file--------------------------
#include "Kryziazodis.h"
#include <string>
#include <iomanip>
#include <fstream>
#include <iostream>
#include "Ieskoma.h"
using namespace std;
const char CDfv[] = "Duom.txt";
const char CRfr[] = "Rezultatai.txt";
const int Cmax = 100; // maximum ammount of words
void Skaityti(const char fv[], Kryziazodis & a, int & k, Ieskoma b[]);
void Spausdinti(const char fr[], Kryziazodis a, int k, Ieskoma b[]);
void RastiZodi(Kryziazodis a, Ieskoma b);
int main()
{
Kryziazodis a;
int k = 0; // number of looking words
Ieskoma b[Cmax];
Skaityti(CDfv, a, k, b);
Spausdinti(CRfr, a, k , b);
for (int i = 0; i < k; i++)
RastiZodi(a, b[i]);
}
void Skaityti(const char fv[], Kryziazodis & a, int & k, Ieskoma b[])
{
int n, m, x, y;
char raide;
Raides r;
string zodis;
ifstream fd(fv);
fd >> n >> m;
a.DetiN(n);
a.DetiM(m);
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
{
fd >> raide;
r.Deti(raide);
a.Deti(i, j, r);
}
fd >> k;
for (int i = 0; i < k; i++)
{
fd >> zodis >> x >> y;
b[i].Deti(zodis, x, y);
}
fd.close();
}
void Spausdinti(const char fr[], Kryziazodis a, int k, Ieskoma b[])
{
ofstream fd(fr);
for (int i = 0; i < a.ImtiN(); i++)
{
for (int j = 0; j < a.ImtiM(); j++)
fd << a.Imti(i,j).ImtiRaide() << " ";
fd << endl;
}
cout << a.Imti(2,2).ImtiRaide();
fd << endl << k << endl;
for (int i = 0; i < k; i++)
fd << b[i].ImtiZodi() << " " << b[i].ImtiX() << " " << b[i].ImtiY() << endl;
fd.close();
}
void RastiZodi(Kryziazodis a, Ieskoma b)
{
int ilgis = b.ImtiZodi().length();
char raide[50];
for (int i = 0; i < ilgis; i++)
raide[i] = b.ImtiZodi()[i];
int x = b.ImtiX()-1;
int y = b.ImtiY()-1;
int ilg = 0;
int vietaX[50];
int vietaY[50];
char tarp = a.Imti(x,y).ImtiRaide();
while (ilg != ilgis)
{
if (a.Imti(x,y).ImtiRaide() == raide[0])
{
vietaX[ilg] = x;
vietaY[ilg] = y;
ilg++;
}
}
} */
|