Advertisement
AnaGocevska

Untitled

Nov 7th, 2015
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.59 KB | None | 0 0
  1. package SamoglaskiSoglaski;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6.  
  7. public class SamoglaskiSoglaski {
  8.    
  9.     public static void pecati(SLL<Character> lista)
  10.     {
  11.         SLLNode<Character> tmp = lista.getFirst();
  12.         while(tmp!=null)
  13.         {
  14.             System.out.print(tmp.element + " ");
  15.             tmp = tmp.succ;
  16.         }
  17.     }
  18.     public static SLL<Character> samoglaski(SLL<Character> lista)
  19.     {
  20.         SLLNode<Character> tmp= lista.getFirst();
  21.         SLL<Character> samog = new SLL<Character>();
  22.        
  23.         while(tmp!=null)
  24.         {
  25.             if(tmp.element == 'a' || tmp.element == 'o' || tmp.element == 'e' || tmp.element == 'i' ||tmp.element == 'u')
  26.             {
  27.                 samog.insertLast(tmp.element);
  28.             }
  29.             tmp = tmp.succ;
  30.         }
  31.         return samog;
  32.     }
  33.    
  34.     public static SLL<Character> soglaski(SLL<Character> lista)
  35.     {
  36.         SLLNode<Character> tmp= lista.getFirst();
  37.         SLL<Character> sog = new SLL<Character>();
  38.        
  39.         while(tmp!=null)
  40.         {
  41.             if(tmp.element != 'a' && tmp.element != 'o' && tmp.element != 'e' && tmp.element != 'i' & tmp.element != 'u')
  42.             {
  43.                 sog.insertLast(tmp.element);
  44.             }
  45.             tmp = tmp.succ;
  46.         }
  47.         return sog;
  48.     }
  49.    
  50.     public static void main(String[] args) throws IOException {
  51.        
  52.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  53.        
  54.         SLL<Character> lista = new SLL<Character>();
  55.         String s = br.readLine();
  56.        
  57.         for(int i=0; i<s.length(); i++)
  58.         {
  59.             lista.insertLast(s.charAt(i));
  60.         }
  61.        
  62.         SLL<Character> samog = samoglaski(lista);
  63.         SLL<Character> sog = soglaski(lista);
  64.        
  65.         pecati(samog);
  66.         System.out.println();
  67.         pecati(sog);
  68.        
  69.     }
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement