Guest User

Untitled

a guest
Oct 18th, 2019
104
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream f("date.in");
  5. ofstream g("date.out");
  6.  
  7. void read(char x[50][50], int n, int m, int viz[50][50])
  8. {
  9. for(int i = 0; i < n; i++)
  10. {
  11. for(int j = 0; j < m; j++)
  12. {
  13. f >> x[i][j];
  14. viz[i][j] = 0;
  15. }
  16. }
  17. }
  18. void print_matrix(char x[50][50],int n,int m)
  19. {
  20. for(int i = 0; i < n; i++)
  21. {
  22. for(int j = 0; j < m; j++)
  23. {
  24. cout << x[i][j];
  25. }
  26. cout << "\n";
  27. }
  28. }
  29.  
  30. bool isValidDiamond(char x[50][50])
  31. {
  32.  
  33. }
  34.  
  35. int main()
  36. {
  37. char x[50][50];
  38. int viz[50][50];
  39. int n,m;
  40. int left_line;
  41. int left_col;
  42.  
  43. f>>n>>m;
  44. read(x,n,m,viz);
  45.  
  46. for(int i = 0; i < n; i++)
  47. {
  48. for(int j = 0; j < m; j++)
  49. {
  50. //varf sus
  51. if(x[i][j] == '/' && x[i][j+1] == 92)
  52. {
  53. //parcurgere pe diagonala
  54. left_line = i+1;
  55. left_col = j;
  56.  
  57. bool gasit = false;
  58. int y_varf_jos = 0;
  59.  
  60. //cout <<"left_line "<< left_line << "\n";
  61.  
  62. //gasire varf de jos
  63. while(!gasit)
  64. {
  65. if(x[left_line][left_col] == 92 && x[left_line][left_col+1] == '/')
  66. gasit = true;
  67. y_varf_jos++;
  68. left_line++;
  69. }
  70.  
  71. //_varf_jos = i+y_varf_jos;
  72.  
  73. bool evalid = true;
  74.  
  75. //cout <<" y varf jos este " << y_varf_jos << "\n";
  76. cout << i << " " << y_varf_jos << "\n";
  77.  
  78.  
  79. int y = i;
  80. int col_jumatate1 = i;
  81. int lin_jumatate1 = j;
  82. int nivel = 1;
  83.  
  84. for(y = i+1; y <= (i+y_varf_jos/2); y++)
  85. {
  86. col_jumatate1 = j-2*nivel+1;
  87. lin_jumatate1 = y;
  88.  
  89. cout << x[y][j-2*nivel+1] << " " << x[y][j+2*nivel] << " " << y <<" "<< j-y+1<< " "<<y << " " << j+y <<"\n";
  90. if(!(x[y][j-2*nivel+1] == '/' && x[y][j+2*nivel] == 92))
  91. {
  92. //inseamna ca nu e deala
  93. evalid = false;
  94. }
  95. nivel++;
  96. }
  97.  
  98. int pas = 1;
  99. int y_nou = y_varf_jos;
  100. int col_jumatate2 = y_nou-j+1;
  101. int lin_jumatate2 = y_nou;
  102.  
  103. for(y_nou = y_varf_jos; y_nou > (i+y_varf_jos/2); y_nou--)
  104. {
  105. col_jumatate2 = y_nou-j+1;
  106. lin_jumatate2 = y_nou;
  107.  
  108. cout << x[y_nou][y_nou-j+1] << " " << x[y_nou][j+pas] << " " <<y_nou <<" "<< y_nou-j+1<< " "<<y_nou << " " << j+pas <<"\n";
  109. if(!(x[y_nou][y_nou-j+1] == 92 && x[y_nou][j+pas] == '/'))
  110. {
  111. //inseamna ca nu e deala
  112. evalid = false;
  113. }
  114. pas++;
  115. }
  116.  
  117. //testare daca se completeaza jumatatile
  118. cout << " testare jumatati : \n";
  119. cout << lin_jumatate1 << " " << col_jumatate1 << endl;
  120. cout << lin_jumatate2 << " " << col_jumatate2 << endl;
  121.  
  122. if(col_jumatate1 != col_jumatate2 || (lin_jumatate1 +1) != lin_jumatate2)
  123. {
  124. evalid = false;
  125. }
  126.  
  127. if(!evalid)
  128. cout << "diamantul ce incepe de la i,j:" << i << " " <<j <<" nu e valid " <<y_varf_jos<< "\n";
  129. else cout << "diamantul ce incepe de la i,j:" << i << " " <<j <<" e valid "<<y_varf_jos<< "\n";
  130.  
  131. }
  132. /*metoda1
  133. if(x[i][j] == '/' && x[i][j+1] == 92 && viz[i][j] != 69){
  134. //daca este varf
  135. //1.daca in dreapta e \ p
  136. if(x[i][j+1] == 92){
  137. int nivel = 1;
  138. int line = i+1;
  139. int col = j-1;
  140. while(x[line][col] == '/' && x[line][col+nivel] == 92){
  141. line++;
  142. col--;
  143. nivel++;
  144. viz[line][col] = 69;
  145. }
  146. //se revine la pozitia normala
  147. col++;
  148. int pas2 = nivel;
  149. int nivel2 = 1;
  150. while(x[line][col] == 92 && x[line][col + pas2] == 92){
  151. line++;
  152. col++;
  153. pas2--;
  154. nivel2++;
  155. viz[line][col] = 69;
  156. }
  157. //jumatate e facut diamantul
  158. if(nivel == nivel2)
  159. {
  160. cout << i << " " << j <<" diamant valid \n";
  161. }
  162. }
  163.  
  164. }
  165. */
  166. }
  167. }
  168.  
  169. //print_matrix(x,n,m);
  170.  
  171. f.close();
  172. g.close();
  173. return 0;
  174. }
RAW Paste Data