0

# Bool 1 - 100

I have tried to make a program in console c# with bool, but i havent been able to make numbers go one after another using bool. I would use just int because that works but i can't right now because i need to do this assignment using bool.

6/8/2017 12:30:57 PM

Karwan Maryame Azar

+6

https://stackoverflow.com/questions/377990/elegantly-determine-if-more-than-one-boolean-is-true try the methods here. this can be used for counting using bool. it is for c#

+6

It should. Hope it does for u too

+6

:( I wish I knew c# better

+4

bool is only 0 or 1

+4

an array of bool?

+4

what have you got so far? have you any code?

+4

this looks like c++ not c#

+1

Don't even know of how to start lol. Array would make it easier, by a lot? I read just some about them and eninumerals i think they are called.

+1

I just got in to programing. I do, one sec.

+1

Heh sorry but i didn't make this fully. I got some part from a book about c#... so Rip me

+1

And some parts online.. That's why i didnt think it would work.

+1

I will try as soon as i get home. Lets hope it works out.. c:

+1

Thanks man.

+1

Been on it all day, yet i havent been able to make the code... everyone has it their own way.. i need a way that works.

0

Yeah.. That's why this is so hard to do.

0

bool generate(function<int(int,int)> randomGenerator,int min,int max,int len,int sum,std::vector<int> &output){ /** * Not possible to produce such a sequence */ if(min*len > sum) return false; if(max*len < sum) return false; int curSum = 0; int left = sum - curSum; int leftIndexes = len-1; int curMax = left - leftIndexes*min; int curMin = left - leftIndexes*max; for(int i=0;i<len;i++){ int num = randomGenerator((curMin< min)?min:curMin,(curMax>max)?max:curMax); output.push_back(num); curSum += num; left = sum - curSum; leftIndexes--; curMax = left - leftIndexes*min; curMin = left - leftIndexes*max; } return true; }

0

This won't work because of the last values. And i am pretty sure the code itself is bad..