Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Помеѓу секој пар 2 броја да се внесе нивната аритметичка средина
- import java.util.Scanner;
- public class AritmetickaSredina {
- public static void transform(SLL<Integer> list){
- SLLNode<Integer> tmp=list.getFirst();
- SLLNode<Integer> next;
- while (tmp!=null){
- next=tmp.succ;
- if(next==null){
- break;
- }
- int el=(tmp.element+next.element)/2;
- tmp=next.succ;
- list.insertBefore(el,next);
- }
- System.out.println(list);
- }
- public static void main(String[] args) {
- Scanner in=new Scanner(System.in);
- int n=in.nextInt();
- SLL<Integer> list=new SLL<>();
- for(int i=0;i<n;i++){
- list.insertLast(in.nextInt());
- }
- transform(list);
- }
- }
Add Comment
Please, Sign In to add comment