Advertisement
ibragimova_mariam

№2 в ряд кодефорсес последняя проба

Jul 21st, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package codeforces_try;
  7.  
  8. /**
  9. * @param args the command line arguments
  10. */
  11. import java.io.BufferedReader;
  12. import java.io.IOException;
  13. import java.io.InputStreamReader;
  14. import java.util.Scanner;
  15.  
  16. public class Codeforces_try {
  17.  
  18. static void proverka(char [][]mass, int isRow){
  19. int st_i, st_j;
  20. int count;
  21. for(int i = 0; i < 10; i ++){
  22. st_i = i;
  23. for(int j = 0; j < 6; j ++){
  24. st_j = j;
  25. count = 0;
  26. for(int k = 0; k < 5; k ++){
  27. if(mass[st_i][st_j] == 'X'){
  28. count++;
  29. }
  30. st_j++;
  31. }
  32. if(count == 4){
  33. isRow = 1;
  34. System.out.println("YES");
  35. }
  36. }
  37. }
  38. }
  39.  
  40. public static void main(String[] args) throws IOException {
  41.  
  42. BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
  43.  
  44. char [][]mass = new char[10][];
  45. for(int i = 0; i < 10; i ++){
  46. mass[i] = input.readLine().toCharArray();
  47. }
  48.  
  49. char temp;
  50.  
  51. int vert = 0, horiz = 0, left_diag = 0, right = 0;
  52.  
  53. for(int q = 0; q < 2; q ++){
  54. if(q == 0){ //vertical
  55. proverka(mass, horiz);
  56. }
  57. if(q == 1){ //horizontal
  58. for(int i = 0; i < 10; i ++){// reverse
  59. for(int j = 0; j < 10; j ++){
  60. if(i <= j){
  61. temp = mass[i][j];
  62. mass[i][j] = mass[j][i];
  63. mass[j][i] = temp;
  64. }
  65. }
  66. }
  67. /*System.out.println("reverse: ");
  68. for(int i = 0; i < 10; i ++){
  69. for(int j = 0; j < 10; j ++){
  70. System.out.print(mass[i][j] + " ");
  71. }
  72. System.out.println();
  73. }*/
  74. proverka(mass, vert);
  75. }
  76. }
  77. System.out.println("horiz=" + horiz + " vert=" + vert);
  78.  
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement