0
I have this list of 1
to 10
.
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Code:
List <Long> lista = new ArrayList();
for (long a = 1; a <= 10; a++) {
lista.add(a);
System.out.print(lista);
}
I would need a sum interspersed in that list, with a variable.
For example:
List <Long> lista = new ArrayList();
long x,z=200;
for (long a = 1; a <= 10; a++) {
x=z+a;
lista.add(x);
}
System.out.print(lista);
}
}
Instead of printing the normal list + 200
:
[201, 202, 203, 204, 205, 206, 207, 208, 209, 210]
I wanted the sum to be interspersed..
[1, 202, 3, 204, 5, 206, 7, 208, 9, 210]
And I also wish I could change that distance from how many jumps to give the sum on the list could be 2
in 2
or 5
in 5
... of 30
in 30
... you understand.. depending on the size of the list... list of 1
for 100
of 1
for 10000
...
Running on the Repl: https://repl.it/repls/ShorttermUnfortunatePasswords
But do you want to add a list and an incremental number ? two lists ? two incremental numbers ? You speak of a list
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
but then does not use it in sum. Moreover do not walk from1
in1
in that list crosses the boundaries, and unless it is "circular" it will not work. All these details are not clear in the question.– Isac
Good evening @Isac, I added the list to the number 200, yes I need that only an incremental number disappear with on this jump list can be 2 in 2... 5 in 5... 3 in 3... I could change that distance that it travels the sum..
– Felipe
Things remain unclear in order to have a satisfactory answer. How would it work to jump from 3 to 3 in this list with only 10 elements ? Make it clear
– Isac
list from 1 to 10.... skipping elements from 3 to 3... and adding with the number 500... [1, 2, 503, 4, 5, 506, 7, 8, 509, 10]
– Felipe
And where does that come from
500
that would be a number that increases or these come from another list ?– Isac
this number increments, it can come from a variable only....
– Felipe