Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1.  
  2. package wordsearch;
  3. import java.io.File;
  4. import java.io.FileNotFoundException;
  5. import java.util.*;
  6. public class Wordsearch {
  7.  
  8. public static void main(String[] args) throws FileNotFoundException {
  9. Scanner emank=new Scanner(new File("meme1.txt"));
  10. Scanner input =new Scanner(new File("meme.txt"));
  11.  
  12. String line="";
  13. int x=-1;
  14. int position=1;
  15. line=input.nextLine();
  16. int storage=Integer.parseInt(line);
  17. String[][] chars=new String[storage][storage];
  18.  
  19. while(input.hasNext()){
  20. x++;
  21. line=input.nextLine();
  22. for (int y = 0; y <storage; y++) {
  23. chars[x][y]=line.substring(y,y+1);
  24. }
  25. }
  26.  
  27. while(emank.hasNext()){
  28. line=emank.nextLine();
  29. for (int i = 0; i <storage; i++) {
  30. for (int j = 0; j <storage; j++) {
  31. if (chars[i][j].compareTo(line.substring(0,1))==0) {
  32. Checksides(String chars[][],line,pos);
  33. }
  34. }
  35. }
  36. }
  37. }
  38.  
  39.  
  40.  
  41. public static void Checksides(String chars[][], String line, int pos){
  42. pos++;
  43.  
  44. int[] row={-1,1, 0,0,-1,-1, 1,1};
  45. int[] col={ 0,0,-1,1,-1, 1,-1,1};
  46.  
  47. for (int i = 0; i < 10; i++) {
  48. int x=row[i];
  49. int y=col[i];
  50. if (chars[x][y].compareTo(line.substring(pos,pos+1))==0) {
  51. Checksides(chars[][],line, pos);
  52. }
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement