Nov 14, 2014 at 7:43am UTC
I want to print a n*n array with words filled(in this case, is 4by4, but could be other size as well). I'm wondering how to align the words and numbers like the sample below.
1 2 3 4 5
0 1 2 3
0 Homer Simpson Cypher Cypher Enchantress
1 Mirage Cerise Spider-Man Toad
2 Homer Simpson Thanos Mirage Cerise
3 Enchantress Thanos Toad Spider-Man
Last edited on Nov 14, 2014 at 8:08am UTC
Nov 14, 2014 at 7:48am UTC
Use tabs to align the headins 0,1,2 and 3.
use printf("%15s\t%10s\t%10s\t%15s\n" );
for the rest
Last edited on Nov 14, 2014 at 7:48am UTC
Nov 14, 2014 at 7:54am UTC
I got the idea but the column and row's size vary and could be 4, 6, 8, or 10. Should I write if statement to do this? I think there are easier ways.