Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream f("date.in");
- ofstream g("date.out");
- void read(char x[50][50], int n, int m, int viz[50][50])
- {
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < m; j++)
- {
- f >> x[i][j];
- viz[i][j] = 0;
- }
- }
- }
- void print_matrix(char x[50][50],int n,int m)
- {
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < m; j++)
- {
- cout << x[i][j];
- }
- cout << "\n";
- }
- }
- bool isValidDiamond(char x[50][50])
- {
- }
- int main()
- {
- char x[50][50];
- int viz[50][50];
- int n,m;
- int left_line;
- int left_col;
- f>>n>>m;
- read(x,n,m,viz);
- for(int i = 0; i < n; i++)
- {
- for(int j = 0; j < m; j++)
- {
- //varf sus
- if(x[i][j] == '/' && x[i][j+1] == 92)
- {
- //parcurgere pe diagonala
- left_line = i+1;
- left_col = j;
- bool gasit = false;
- int y_varf_jos = 0;
- //cout <<"left_line "<< left_line << "\n";
- //gasire varf de jos
- while(!gasit)
- {
- if(x[left_line][left_col] == 92 && x[left_line][left_col+1] == '/')
- gasit = true;
- y_varf_jos++;
- left_line++;
- }
- //_varf_jos = i+y_varf_jos;
- bool evalid = true;
- //cout <<" y varf jos este " << y_varf_jos << "\n";
- cout << i << " " << y_varf_jos << "\n";
- int y = i;
- int col_jumatate1 = i;
- int lin_jumatate1 = j;
- int nivel = 1;
- for(y = i+1; y <= (i+y_varf_jos/2); y++)
- {
- col_jumatate1 = j-2*nivel+1;
- lin_jumatate1 = y;
- cout << x[y][j-2*nivel+1] << " " << x[y][j+2*nivel] << " " << y <<" "<< j-y+1<< " "<<y << " " << j+y <<"\n";
- if(!(x[y][j-2*nivel+1] == '/' && x[y][j+2*nivel] == 92))
- {
- //inseamna ca nu e deala
- evalid = false;
- }
- nivel++;
- }
- int pas = 1;
- int y_nou = y_varf_jos;
- int col_jumatate2 = y_nou-j+1;
- int lin_jumatate2 = y_nou;
- for(y_nou = y_varf_jos; y_nou > (i+y_varf_jos/2); y_nou--)
- {
- col_jumatate2 = y_nou-j+1;
- lin_jumatate2 = y_nou;
- cout << x[y_nou][y_nou-j+1] << " " << x[y_nou][j+pas] << " " <<y_nou <<" "<< y_nou-j+1<< " "<<y_nou << " " << j+pas <<"\n";
- if(!(x[y_nou][y_nou-j+1] == 92 && x[y_nou][j+pas] == '/'))
- {
- //inseamna ca nu e deala
- evalid = false;
- }
- pas++;
- }
- //testare daca se completeaza jumatatile
- cout << " testare jumatati : \n";
- cout << lin_jumatate1 << " " << col_jumatate1 << endl;
- cout << lin_jumatate2 << " " << col_jumatate2 << endl;
- if(col_jumatate1 != col_jumatate2 || (lin_jumatate1 +1) != lin_jumatate2)
- {
- evalid = false;
- }
- if(!evalid)
- cout << "diamantul ce incepe de la i,j:" << i << " " <<j <<" nu e valid " <<y_varf_jos<< "\n";
- else cout << "diamantul ce incepe de la i,j:" << i << " " <<j <<" e valid "<<y_varf_jos<< "\n";
- }
- /*metoda1
- if(x[i][j] == '/' && x[i][j+1] == 92 && viz[i][j] != 69){
- //daca este varf
- //1.daca in dreapta e \ p
- if(x[i][j+1] == 92){
- int nivel = 1;
- int line = i+1;
- int col = j-1;
- while(x[line][col] == '/' && x[line][col+nivel] == 92){
- line++;
- col--;
- nivel++;
- viz[line][col] = 69;
- }
- //se revine la pozitia normala
- col++;
- int pas2 = nivel;
- int nivel2 = 1;
- while(x[line][col] == 92 && x[line][col + pas2] == 92){
- line++;
- col++;
- pas2--;
- nivel2++;
- viz[line][col] = 69;
- }
- //jumatate e facut diamantul
- if(nivel == nivel2)
- {
- cout << i << " " << j <<" diamant valid \n";
- }
- }
- }
- */
- }
- }
- //print_matrix(x,n,m);
- f.close();
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement