1,075,692 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Posts by wen_cai which have been Voted Up

If I were to guess where you get your index out of bounds error it would be on line 38. Your initial pass through your 2nd while loop will be fine as you have set your col value to zero but once you finish that 2nd while loop, the value does not set back to zero. It will pass your maximum value of 100 if you have more than 100 tokens.

wen_cai
Junior Poster in Training
64 posts since May 2012
Reputation Points: -3
Solved Threads: 17
Skill Endorsements: 2

for ( int prime = 2; prime <= num; prime++ )

Correct me if I am wrong. Your prime must be less than number not less than or equal to number. This is because if prime and number are equal, then it will always return false and will never return true. Also, line 10 of your 1st solution should be outside of the for loop. Else it will only do the check once.

wen_cai
Junior Poster in Training
64 posts since May 2012
Reputation Points: -3
Solved Threads: 17
Skill Endorsements: 2

First, '==' operator is not an assignment operator. It is comparison. Assignment operator is '='.

Second, the if statement is used to set the first value as your smallest value since it has nothing to compare to, it will always be the smallest value in your random number.

Have fun! = )

wen_cai
Junior Poster in Training
64 posts since May 2012
Reputation Points: -3
Solved Threads: 17
Skill Endorsements: 2

YouList.Add(Value) to add item.

Then use a loop to sum the value of your item.

wen_cai
Junior Poster in Training
64 posts since May 2012
Reputation Points: -3
Solved Threads: 17
Skill Endorsements: 2

From the code above, do you mean a constant? You can create a static class where you can just call MyClass.functionc(). You do not need to create a new instance of the class. If that is what you are looking for.

wen_cai
Junior Poster in Training
64 posts since May 2012
Reputation Points: -3
Solved Threads: 17
Skill Endorsements: 2
 
© 2013 DaniWeb® LLC
Page rendered in 0.0493 seconds using 2.49MB