Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. public static DoublyLinkedList<Integer> calcMMS(DoublyLinkedList<Integer> serie, Integer periodo){
  2. DoublyLinkedList<Integer> mms=new DoublyLinkedList<>();
  3. int i=0;
  4. int somaElementos;
  5. DoublyLinkedList<Integer> soma=new DoublyLinkedList<>();
  6. for(Integer numero: serie){
  7. soma.addLast(numero);
  8. if(soma.size()>periodo){
  9. soma.removeFirst();
  10. }
  11. if(i<periodo){
  12. mms.addLast(0);
  13. }else{
  14. somaElementos=0;
  15. for(Integer valorSoma:soma){
  16. somaElementos+=valorSoma;
  17. }
  18. mms.addLast(somaElementos/periodo);
  19. }
  20. i++;
  21. }
  22. return mms;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement