Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package wordsearch;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.*;
- public class Wordsearch {
- public static void main(String[] args) throws FileNotFoundException {
- Scanner emank=new Scanner(new File("meme1.txt"));
- Scanner input =new Scanner(new File("meme.txt"));
- String line="";
- int x=-1;
- int position=1;
- line=input.nextLine();
- int storage=Integer.parseInt(line);
- String[][] chars=new String[storage][storage];
- while(input.hasNext()){
- x++;
- line=input.nextLine();
- for (int y = 0; y <storage; y++) {
- chars[x][y]=line.substring(y,y+1);
- }
- }
- while(emank.hasNext()){
- line=emank.nextLine();
- for (int i = 0; i <storage; i++) {
- for (int j = 0; j <storage; j++) {
- if (chars[i][j].compareTo(line.substring(0,1))==0) {
- Checksides(String chars[][],line,pos);
- }
- }
- }
- }
- }
- public static void Checksides(String chars[][], String line, int pos){
- pos++;
- int[] row={-1,1, 0,0,-1,-1, 1,1};
- int[] col={ 0,0,-1,1,-1, 1,-1,1};
- for (int i = 0; i < 10; i++) {
- int x=row[i];
- int y=col[i];
- if (chars[x][y].compareTo(line.substring(pos,pos+1))==0) {
- Checksides(chars[][],line, pos);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement