Martina312

Правилни реченици

Feb 4th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PravilnaRecenicaLista {
  4.     public static void preuredi(SLL<Character> list){
  5.            SLLNode<Character> tmp=list.getFirst();
  6.  
  7.            while(tmp!=null){
  8.                SLLNode<Character> zacuvaj=tmp;
  9.  
  10.                while(tmp.succ.element!=' ' && tmp.succ.element!='.'){
  11.                    tmp=tmp.succ;
  12.                }
  13.  
  14.                list.insertBefore(tmp.element,zacuvaj);
  15.                SLLNode<Character> kopija=tmp;
  16.                list.delete(tmp);
  17.                tmp=kopija.succ;
  18.  
  19.                if(tmp.element==' ')
  20.                    tmp=tmp.succ;
  21.  
  22.                if(tmp.element=='.'){
  23.                    System.out.println(list);
  24.                    return;
  25.                }
  26.            }
  27.     }
  28.     public static void main(String[] args) {
  29.         Scanner in=new Scanner(System.in);
  30.         SLL<Character> list=new SLL<>();
  31.  
  32.         String line=in.nextLine();
  33.         for(int i=0;i<line.length();i++){
  34.             list.insertLast(line.charAt(i));
  35.         }
  36.         preuredi(list);
  37.     }
  38. }
Add Comment
Please, Sign In to add comment