-1

I'm writing a code that in some point it has to prints different 16 values in 4 columns and 4 rows. i know the for loop method but this looks different. Anybody have any idea? Also, the input that was entered from the user in hex, in the output we should let just the last 2 characters. for example, suppose that the input is like:

#0: 1991
#1: 2696
#2: c8c
#3: 11eb
#4: 2689
#5: 1eae
#6: 4dd
#7: 2696
#8: 1991
#9: 2696
#10: 861
#11: 2696
#12: 4f1
#13: 1eda
#14: cad
#15: 1eda

the output should be like:

GENERAL REGISTERS:

#0: 91       #4: 89       #8: 91        #12: f1
#1: 96       #5: ae       #9: 96        #13: da
#2: 8c       #6: dd       #10: 61       #14: ad
#3: eb       #7: 96       #11: 96       #15: da
  • 2
    What code do you have so far? – Mike Tunnicliffe Jan 27 '15 at 19:07
  • 1
    The output is 4 lines. The first line contains the elements at index 0, 4, 8 and 12: that's 0 * 4 + 0, 1 * 4 + 0, 2 * 4 + 0 and 3 * 4 + 0. The second line contains the elements at index 1, 5, 9, 13 (that's 0 * 4 + 1, 1 * 4 + 1, 2 * 4 + 1 and 3 * 4 + 1. There's some logic there. – JB Nizet Jan 27 '15 at 19:07
  • Thanks @JBNizet ! that's a smart way of doing it – user3781457 Jan 27 '15 at 20:15

1 Answers1

1

substring[ing] off the last 2 bytes should be trival. Getting the elements for the columns like @JB Nizet said is just a little math.

For formatting this seems like most of what you want output in table format

Community
  • 1
  • 1
Terry
  • 911
  • 10
  • 26