Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class Oppgave3b {
- public static void main(String[] args) throws IOException{
- String ord="", setning;
- char bokstav='a', bokstav2, bokstav1;
- int a=0, lengde, i=0, j=0;
- int teller=0, teller2;
- String[] ordMatrise = new String[100];
- FileReader stromFraFil = new FileReader("ordsamling.txt");
- BufferedReader stromFraBuffer = new BufferedReader(stromFraFil);
- setning = stromFraBuffer.readLine();
- lengde = setning.length();
- while (a<lengde) {
- bokstav = setning.charAt(a);
- if ((int)bokstav == 32) {
- ordMatrise[i]=ord;
- ord="";
- i++;
- }
- else {
- ord=ord+bokstav;
- }
- a++;
- }
- ordMatrise[i] = ord;
- for (a=0; a<=i; a++) {
- System.out.println(ordMatrise[a]);
- }
- for (i=0; i<ordMatrise.length; i++) {
- if(ordMatrise[i] != null) {
- teller++;
- }
- }
- for(a=0; a<teller; a++) {
- teller2=0;
- i=0;
- j=0;
- while (j<teller) {
- teller2=0;
- i=0;
- while ((i<ordMatrise[a].length()) && (i<ordMatrise[j].length())) {
- bokstav1 = ordMatrise[a].charAt(i);
- bokstav2 = ordMatrise[j].charAt(i);
- if ((int)bokstav1 == (int)bokstav2) {
- teller2++;
- }
- if ((teller2==ordMatrise[a].length()) && !(ordMatrise[a].equals(ordMatrise[j]))) {
- System.out.println("Betraktet ord..: "+ordMatrise[j]+" Ordstamme..: "+ordMatrise[a]);
- }
- i++;
- }
- j++;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment