0
Prompt the user to input 3 integer values and print these values in forward and reversed order
for an example below,given the following (3) numbers: 14 30 20
2 Réponses
0
PYTHON -
--------------------------------------
forward=[]
backward=[]
first=14
second=30
third=20
forward.append(first)
forward.append(second)
forward.append(third)
backward.append(third)
backward.append(second)
backward.append(first)
print("")
for i in range(len(forward)):
print(forward[i], end=' ')
print("")
for i in range(len(backward)):
print(backward[i], end=' ')
print("")
0
JAVA -
---------------------------
int first=14, second=30, third=20;
ArrayList<Integer> forward = new ArrayList <Integer>();
ArrayList<Integer> backward = new ArrayList <Integer>();
forward.add(first);
forward.add(second);
forward.add(third);
backward.add(third);
backward.add(second);
backward.add(first);
int fsize=forward.size();
int bsize=backward.size();
for(int i=0; i<fsize; i++){
System.out.print(forward.get(i) + " ");
}
System.out.print("\n");
for(int i=0; i<bsize; i++){
System.out.print(backward.get(i) + " ");
}