Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. public static DoublyLinkedList<Integer> calcMMS(DoublyLinkedList<Integer> serie, Integer period) {
  2. DoublyLinkedList<Integer> mms = new DoublyLinkedList<>();
  3. DoublyLinkedList<Integer> aux = new DoublyLinkedList<>();
  4.  
  5. int media = 0;
  6. ListIterator<Integer> it = serie.listIterator();
  7. int contador = 0;
  8. while(it.hasNext()) {
  9. media += it.next();
  10. contador++;
  11. if(contador < period) {
  12. mms.addLast(0);
  13. continue;
  14. } else if(contador > period) {
  15. it.previous();
  16. it.previous();
  17. it.previous();
  18. media -= it.previous();
  19. it.next();
  20. it.next();
  21. it.next();
  22. it.next();
  23. }
  24.  
  25.  
  26. mms.addLast(media / period);
  27. }
  28.  
  29. return mms;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement