• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help with creating a diagonal cross  RSS feed

 
Sebastian Hamilton
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to create a diagonal cross however I can not figure out how to do the upper left side of it.
Currently I am getting
0*
1--*
2---*
3 *--*
4*-----*
I want to get it to look like
0*------*
1 *--*
2----*
3 *---*
4*------ *
( I replaced spaces with -)
So far I have

Can any one help me with the final corner please?
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I added code tags to your post. Always use them: doesn't it look better. The code tabs would also make spaces appear so you can write…if you change java to text in the code tags. I also removed some of the excess tabs; you had most of the code far too far to the right. Please be careful with { and }, which are inconsistent. you should have { at the very end of the line or on a line by itself (depending what indentation convention you use) but all indentation conventions have } always on a line by itself.
This does not apply to array initialisers.
I suggest you go to a sheet of paper and write the places where you want the *s and work out the formula. Just be careful about the middle row where you only want one *
Think about 2 + 3 = 5 and 3 + 2 = 5. That might be easier than the arithmetic you are doing. You might also count 0…4 rather than 1…5.
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that the \ diagonal is where i and j are the same value.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!