Chapter 12: Pointers and Arrays

Example reverse3.c, Page 264

In [1]:
N=10
li = raw_input("Enter %d numbers: " % N) #accepting input in list
a = map(int, li.split()) 
print "In reverse order: ",
for i in a[::-1]: #print reversed list
    print i,
Enter 10 numbers: 34 82 49 102 7 94 23 11 50 31
In reverse order:  31 50 11 23 94 7 102 49 82 34
In [ ]: