Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static DoublyLinkedList<Integer> calcMMS(DoublyLinkedList<Integer> serie, Integer period) {
- DoublyLinkedList<Integer> mms = new DoublyLinkedList<>();
- DoublyLinkedList<Integer> aux = new DoublyLinkedList<>();
- int media = 0;
- ListIterator<Integer> it = serie.listIterator();
- int contador = 0;
- while(it.hasNext()) {
- media += it.next();
- contador++;
- if(contador < period) {
- mms.addLast(0);
- continue;
- } else if(contador > period) {
- it.previous();
- it.previous();
- it.previous();
- media -= it.previous();
- it.next();
- it.next();
- it.next();
- it.next();
- }
- mms.addLast(media / period);
- }
- return mms;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement