Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

C# easy homework, math not working. int equal = numbers.max()-numbers.min() <- ??

This is the working code for UInt64 numbers which mean that you can insert From 0 to 18,446,744,073,709,551,615 which equals 2^64 − 1 numbers.

I have also commented the code so to be understandable.


This is Consoled based algorythm just change it and modify it into your app!
Code
//First of all we need UInt64 to calculate really long numbers.
string Input = "18446744073709551615,100";
/*We split the numbers in the text by ',' (comma)
and put them in an array named Numbers*/
string[] Numbers = Input.Split(',');

//This will help us to convert the string into number.
UInt64[] ConvertedNum = new UInt64[Numbers.Length];

/*We convert the string into an integer and put it
in the tolur array.*/
for (int i = 0; i < Numbers.Length; i++)
{
  ConvertedNum[i] = Convert.ToUInt64(Numbers[i]);

}

//We Find the Difference between the max and the min Number.
UInt64 Difference = ConvertedNum.Max() - ConvertedNum.Min();
Console.WriteLine("Were read into the numbers:\n" + Input +
"\nBut the difference between the highest and lowest number is:\n" + Difference);

Console.ReadKey();

Execution Result:
Code
Were read into the numbers:
18446744073709551615,100
But the difference between the highest and lowest number is:
18446744073609551615
@Ghost. Should we read your sound and well in code commented answer as a sign you're irritated by the lack of self involvement of those lazy "students" expecting us to do their homework ?
(Feb 3, 2012 06:46 PM)E25EB8582FF05BF Wrote:  @Ghost. Should we read your sound and well in code commented answer as a sign you're irritated by the lack of self involvement of those lazy "students" expecting us to do their homework ?
Well he did the half job so i just help a little to complete! Of course i'm not the guy that support lazy Students! I'm a Univercity student and i hate guys that C/P other work and present them us theirs!

(Feb 4, 2012 04:56 AM)svavart Wrote:  I'm at the early stage of learning the programming basics with c# and there are already plenty of students to lazy to do their own work. Unfortunately for them there is a program that cross-checks all the students projects when you've made it to advanced programming.
Well if it's like that. . .
Good Then! 🙂


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Will PattersonSep 9, 2021 08:45 AM 6 198 Sep 9, 2021 08:45 AM
Last Post: ThinWhiteDuke
[C] by MaskinApr 21, 2021 01:52 AM 5 326 Apr 21, 2021 01:52 AM
Last Post: Vector Dynamics
[Python] by madeha elsayedxxxxMay 17, 2020 10:01 PM 1 142 May 17, 2020 10:01 PM
Last Post: District