Guest User

Untitled

a guest
Jul 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class Oppgave3b {
  4.  
  5. public static void main(String[] args) throws IOException{
  6.  
  7. String ord="", setning;
  8. char bokstav='a', bokstav2, bokstav1;
  9. int a=0, lengde, i=0, j=0;
  10. int teller=0, teller2;
  11. String[] ordMatrise = new String[100];
  12. FileReader stromFraFil = new FileReader("ordsamling.txt");
  13. BufferedReader stromFraBuffer = new BufferedReader(stromFraFil);
  14.  
  15. setning = stromFraBuffer.readLine();
  16. lengde = setning.length();
  17.  
  18. while (a<lengde) {
  19.  
  20. bokstav = setning.charAt(a);
  21.  
  22. if ((int)bokstav == 32) {
  23.  
  24. ordMatrise[i]=ord;
  25. ord="";
  26. i++;
  27. }
  28.  
  29. else {
  30.  
  31. ord=ord+bokstav;
  32. }
  33. a++;
  34. }
  35.  
  36. ordMatrise[i] = ord;
  37.  
  38. for (a=0; a<=i; a++) {
  39.  
  40. System.out.println(ordMatrise[a]);
  41. }
  42.  
  43. for (i=0; i<ordMatrise.length; i++) {
  44.  
  45. if(ordMatrise[i] != null) {
  46.  
  47. teller++;
  48. }
  49. }
  50.  
  51. for(a=0; a<teller; a++) {
  52.  
  53. teller2=0;
  54. i=0;
  55. j=0;
  56.  
  57. while (j<teller) {
  58.  
  59. teller2=0;
  60. i=0;
  61.  
  62. while ((i<ordMatrise[a].length()) && (i<ordMatrise[j].length())) {
  63.  
  64. bokstav1 = ordMatrise[a].charAt(i);
  65. bokstav2 = ordMatrise[j].charAt(i);
  66.  
  67. if ((int)bokstav1 == (int)bokstav2) {
  68.  
  69. teller2++;
  70. }
  71.  
  72.  
  73. if ((teller2==ordMatrise[a].length()) && !(ordMatrise[a].equals(ordMatrise[j]))) {
  74.  
  75. System.out.println("Betraktet ord..: "+ordMatrise[j]+" Ordstamme..: "+ordMatrise[a]);
  76. }
  77. i++;
  78. }
  79. j++;
  80. }
  81. }
  82.  
  83.  
  84. }
  85. }
Add Comment
Please, Sign In to add comment