;_;Are you a sorcerer?
I've spent the last ten minutes cleanup honey tea off my keyboard and monitor.
It was kind of worth it. ^_^;
Soma
;_;Are you a sorcerer?
I've spent the last ten minutes cleanup honey tea off my keyboard and monitor.
It was kind of worth it. ^_^;
Soma
“Salem Was Wrong!” -- Pedant Necromancer
“Four isn't random!” -- Gibbering Mouther
I think I understand the code now I replaced the space in the output with an A and it help me visual what the code was doing The only thing I haven't done was center it on the screen but I might ask my teacher about when I get a chance here's the code if anyone's interested
Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Chapter6Problem14 { class Program { static void Main() { int rows = 11; int a, b, c, d, e; for (a = 1; a <= rows / 2 + 1; a++) { for (b = 1; b <= rows - a; b++) Console.Write("{0}", " "); for (c = 1; c <= (2 * a) - 1; c++) Console.Write("{0}", "X"); Console.WriteLine(); } for (e = 1; e <= rows - 2; e++) Console.Write("{0}"," "); for (d = 1; d <= rows / 2 - 2; d++) Console.Write("{0}","X"); Console.WriteLine(); Console.ReadKey(); } } }
Good idea! Nice to see you didn't give up.
Some other suggestions when you're having trouble:
- Close your editor and grab a pen(cil) and paper
- Work out exactly what you have to do before you start to code
- Break the problem down into sub-problems (and those sub-problems into further sub-problems where necessary)
- Take a break
The final suggestion (take a break) is recommended because you really can get frustrated and possibly angry. This causes your body to release cortisol and epinephrine (and probably other hormones) which engage your fight/flight response... and you can't think properly when you're like that.
Last edited by Hodor; 03-21-2014 at 04:57 AM.
Good Advice!
Some notes, if I may:
- Try to use descriptive variable names. If you just use a list of arbitrary single letters for variable names, it's much easier to lose track of what variable is being used for what.
- You don't need that many variables. You can re-use variables outside of the scope in which they were defined. For example, you could get away with just "row" and "column", or at least "r" and "c" or even "x" and "y" if it were clear what they represent.
- Console.Write() does not require a format string.could simply be rewritten asCode:Console.Write("{0}", "X").Code:Console.Write("X")
Last edited by itsme86; 03-23-2014 at 12:40 PM.
If you understand what you're doing, you're not learning anything.
Ok I'll keep that in mind I also might try and rewrite it later 2