Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PomaliOdX<E>{
- public void change(SLL<Integer> list, int x){
- SLLNode<Integer> tmp=list.getFirst();
- SLLNode<Integer> before=null;
- while(tmp!=null){
- if(tmp.element>=x){
- before=tmp;
- break;
- }
- tmp=tmp.succ;
- }
- tmp=tmp.succ;
- while(tmp!=null){
- if(tmp.element<x){
- list.insertBefore(tmp.element, before);
- SLLNode<Integer> kopija=tmp;
- list.delete(tmp);
- tmp=kopija.succ;
- }
- else
- tmp=tmp.succ;
- }
- System.out.println(list);
- }
- public static void main(String[] args) {
- Scanner in=new Scanner(System.in);
- int x=3;
- SLL<Integer> list=new SLL<>();
- for(int i=0;i<6;i++){
- list.insertLast(in.nextInt());
- }
- PomaliOdX<Integer> hm=new PomaliOdX<>();
- hm.change(list,x);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement