Quote:
Originally Posted by punky
I did more or less the same. Just one suggestion i'd make regarding your code Damien:
|
I'll just point out a few things:
Int32 is actually the structure that contains "int" - so you can just as easily use 'int' or actually use an implicitly typed local variable - 'var' as it will actually pick up that your variable type is an integer.
Int32 is generally used to parse or switch another variable type into the integer type (Int32.Parse) or set the maximum or minimum value of a specified integer.
Good job with the if statements though - I like how you ignored the curly braces as they're not necessary when you only have the one line of code being executed.
However - your code will simply run through and then close when it's finished calculating all of the multiples, what you may want to do is stick
Code:
Console.ReadKey(true);
after your for loop - this will then only exit on keypress.
---------- Post added at 10:06 ---------- Previous post was at 09:54 ----------
Quote:
Originally Posted by Damien
Opps! Miss that. Indeed.
---------- Post added at 21:29 ---------- Previous post was at 21:28 ----------
Let's do that one next then. An array of 10 random numbers should be fine...
I'll try tomorrow.
|
For this, you can just use, in C#:
Code:
Array.Sort(yourArray);
but... that's cheating!
Seeing as you're only using 10 random numbers, I suggest you actually create your own code for a bubble sort algorithm -
http://en.wikipedia.org/wiki/Bubble_sort