View difference between Paste ID: vYzT3HpR and V9Z3c9sp
SHOW: | | - or go back to the newest paste.
1
import java.util.Scanner;
2
public class Main{
3
	public static void main(String[] args){		
4-
		int count = -1;
4+
		int countofinputs = -1;
5-
		int count2 = 0;		
5+
		int countofpiecesfound = 0;		
6-
		int joey = 0;
6+
		int endinput = 0;
7
		int a[][] = new int[9][9];		
8-
		while(joey == 0){
8+
		while(endinput == 0){
9
			System.out.println("Enter Row: ");
10
			Scanner scan = new Scanner(System.in);
11
			int r = scan.nextInt();
12
			System.out.println("Enter Column: ");
13
			Scanner scan2 = new Scanner(System.in);
14
			int c = scan2.nextInt();							
15
			a[r][c]= 1;
16-
			count++;
16+
			countofinputs++;
17
		if(r==0 && c==0){
18-
			joey = 1;
18+
			endinput = 1;
19
		}
20
		}	
21-
		for(int row=1; row<=8; row++){
21+
		for(int row=1; row<=7; row++){
22-
			for(int column=1; column<=8; column++){
22+
			for(int column=1; column<=7; column++){		
23-
				for(int i=1; i<8; i++){		
23+
24
				for(int i=1; i<7; i++){
25
				if(row-i >= 1 && column-i >= 1){
26
					if(a[row-i][column-i] == 1)
27-
						count2++;
27+
						countofpiecesfound++;
28
				}				
29
				else		
30
					break;
31
				}
32
				// Up
33
				for(int i=1; i<7; i++){
34-
						count2++;
34+
35
					if(a[row-i][column] == 1)
36
						countofpiecesfound++;
37
				}
38
				else
39
					break;
40
				}
41-
						count2++;
41+
42
				for(int i=1; i<7; i++){
43
				if(row-i >= 1 && column+i <= 7){
44
					if(a[row-i][column+i] == 1)
45
						countofpiecesfound++;
46
				}
47
				else
48-
						count2++;
48+
49
				}
50
				// Right
51
				for(int i=1; i<7; i++){
52
				if(column-i >= 1){
53
					if(a[row][column-i] == 1)
54
						countofpiecesfound++;
55-
						count2++;
55+
56
				else
57
					break;
58
				}
59
				// Left
60
				for(int i=1; i<7; i++){
61
				if(column+1 <= 7){
62-
						count2++;
62+
63
						countofpiecesfound++;
64
				}
65
				else
66
					break;
67
				}
68
				//Down
69-
						count2++;
69+
				for(int i=1; i<7; i++){
70
				if(row+i <= 7){
71
					if(a[row+i][column] == 1)
72
						countofpiecesfound++;
73
				}
74
				else
75
					break;
76-
						count2++;
76+
77
				// Down Left Diagonal
78
				for(int i=1; i<7; i++){
79
				if(row+i <= 7 && column-i >= 1){
80-
			}
80+
81-
				if(count2 == count)
81+
						countofpiecesfound++;
82
				}
83-
				//System.out.println(count2);
83+
84
					break;
85-
			count2 = 0;
85+
86
				// Down Right Diagonal
87-
	}
87+
				for(int i=1; i<7; i++){
88-
}
88+
89
					if(a[row+i][column+i] == 1)
90
						countofpiecesfound++;
91
				}
92
				else
93
					break;
94
				}
95
				if(countofpiecesfound == countofinputs)
96
					System.out.println(row + "," + column);
97
				}
98
			countofpiecesfound = 0;
99
			}	
100
		}
101
	}