Bool 1 - 100 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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.

8th Jun 2017, 12:30 PM
Karwan Maryame Azar
Karwan Maryame Azar - avatar
17 Answers
+ 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#
8th Jun 2017, 12:43 PM
jay
jay - avatar
+ 6
It should. Hope it does for u too
8th Jun 2017, 12:47 PM
jay
jay - avatar
+ 6
:( I wish I knew c# better
8th Jun 2017, 9:23 PM
jay
jay - avatar
+ 4
bool is only 0 or 1
8th Jun 2017, 12:32 PM
jay
jay - avatar
+ 4
an array of bool?
8th Jun 2017, 12:33 PM
jay
jay - avatar
+ 4
what have you got so far? have you any code?
8th Jun 2017, 12:35 PM
jay
jay - avatar
+ 4
this looks like c++ not c#
8th Jun 2017, 12:41 PM
jay
jay - avatar
+ 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.
8th Jun 2017, 12:35 PM
Karwan Maryame Azar
Karwan Maryame Azar - avatar
+ 1
I just got in to programing. I do, one sec.
8th Jun 2017, 12:35 PM
Karwan Maryame Azar
Karwan Maryame Azar - avatar
+ 1
Heh sorry but i didn't make this fully. I got some part from a book about c#... so Rip me
8th Jun 2017, 12:42 PM
Karwan Maryame Azar
Karwan Maryame Azar - avatar
+ 1
And some parts online.. That's why i didnt think it would work.
8th Jun 2017, 12:43 PM
Karwan Maryame Azar
Karwan Maryame Azar - avatar
+ 1
I will try as soon as i get home. Lets hope it works out.. c:
8th Jun 2017, 12:46 PM
Karwan Maryame Azar
Karwan Maryame Azar - avatar
+ 1
Thanks man.
8th Jun 2017, 12:47 PM
Karwan Maryame Azar
Karwan Maryame Azar - avatar
+ 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.
8th Jun 2017, 6:53 PM
Karwan Maryame Azar
Karwan Maryame Azar - avatar
0
Yeah.. That's why this is so hard to do.
8th Jun 2017, 12:32 PM
Karwan Maryame Azar
Karwan Maryame Azar - avatar
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; }
8th Jun 2017, 12:36 PM
Karwan Maryame Azar
Karwan Maryame Azar - avatar
0
This won't work because of the last values. And i am pretty sure the code itself is bad..
8th Jun 2017, 12:37 PM
Karwan Maryame Azar
Karwan Maryame Azar - avatar