C# Numbers game
-
I have converted game from pascal to C# but when I start program and type in target value and values for finding that value program gives me error:[^] Pascal source: [Pascal] Moj Broj - Pastebin.com[^] C# Source: [C#] Moj Broj C# - Pastebin.com[^]
-
I have converted game from pascal to C# but when I start program and type in target value and values for finding that value program gives me error:[^] Pascal source: [Pascal] Moj Broj - Pastebin.com[^] C# Source: [C#] Moj Broj C# - Pastebin.com[^]
You've asked enough questions here to know how to ask a question: and linking to code on a different site isn't good. And just dumping two sets of code on us and saying "it don't work" isn't going to get you very far either. We've already told you that just blindly converting between Pascal and C# is a good idea. What have you done to sort this out? What have you found out about this problem by using the debugger?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
You've asked enough questions here to know how to ask a question: and linking to code on a different site isn't good. And just dumping two sets of code on us and saying "it don't work" isn't going to get you very far either. We've already told you that just blindly converting between Pascal and C# is a good idea. What have you done to sort this out? What have you found out about this problem by using the debugger?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
I change from bool[] uzet=new bool[6]; to bool[] uzet=new bool[7]; but I get this error: void oznaci_po_redu(int s) { l = 0; while (s > 0) { l++; if (!uzet[l]) s--; -----Index was outside the bounds of the array-------- } uzet[l] = true; }
Well, clearly you need to find out what value
s
has before you enter the loop, and why it might be larger than the number of elements. We can't do that for you: you need the debugger to find out!Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Well, clearly you need to find out what value
s
has before you enter the loop, and why it might be larger than the number of elements. We can't do that for you: you need the debugger to find out!Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Then look at the code using the debugger and see exactly what is happening each time it goes round the loop. It's pretty obvious if you just pay attention to what you have written ... and the debugger would show that that immediately...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Well, clearly you need to find out what value
s
has before you enter the loop, and why it might be larger than the number of elements. We can't do that for you: you need the debugger to find out!Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
No, it's
l
void oznaci_po_redu(int s)
{
l = 0;
while (s > 0)
{
l++;
if (!uzet[l]) s--; -----Index was outside the bounds of the array--------
}
uzet[l] = true;
}But it gets increased while s is non zero, and when does s get reduced?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
No, it's
l
void oznaci_po_redu(int s)
{
l = 0;
while (s > 0)
{
l++;
if (!uzet[l]) s--; -----Index was outside the bounds of the array--------
}
uzet[l] = true;
}But it gets increased while s is non zero, and when does s get reduced?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
:-D A quick visit with Mr Debug would have shown the OP as well! :laugh:
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
:-D A quick visit with Mr Debug would have shown the OP as well! :laugh:
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
I changed this loop for (prog.u = 1; prog.u < 6; prog.u++) to for (prog.u = 0; prog.u < 5; prog.u++) now I have this error: imageshack.com/a/img923/8677/WIBoHG.png
-
I changed this loop for (prog.u = 1; prog.u < 6; prog.u++) to for (prog.u = 0; prog.u < 5; prog.u++) now I have this error: imageshack.com/a/img923/8677/WIBoHG.png
-
I changed this loop for (prog.u = 1; prog.u < 6; prog.u++) to for (prog.u = 0; prog.u < 5; prog.u++) now I have this error: imageshack.com/a/img923/8677/WIBoHG.png
And what error is that? It's less work for you to copy and paste the actual text, than to post a screen shot on a dodgy image site that I'm not planning on visiting...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
And what error is that? It's less work for you to copy and paste the actual text, than to post a screen shot on a dodgy image site that I'm not planning on visiting...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Well, the error message pretty much explains itself. Mathematics does not allow you to divide by zero, so you should probably make sure your application doesn't try to do that, wouldn't you say? The fun bit is finding out why your application is trying at all. And - again - that's where you and Mr Debugger get to be good friends, because he's the one that tells you how the divisor came to be zero: which is pretty much essential to preventing it in future. Seriously, get used to the debugger - it's a powerful, flexible tool that most developers spend a considerable amount of time with. It's a lot more fun - and a lot quicker - to find the information than it is to ask here. Especially as most of the time we have to say "use the debugger to get information" anyway! :laugh:
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Well, the error message pretty much explains itself. Mathematics does not allow you to divide by zero, so you should probably make sure your application doesn't try to do that, wouldn't you say? The fun bit is finding out why your application is trying at all. And - again - that's where you and Mr Debugger get to be good friends, because he's the one that tells you how the divisor came to be zero: which is pretty much essential to preventing it in future. Seriously, get used to the debugger - it's a powerful, flexible tool that most developers spend a considerable amount of time with. It's a lot more fun - and a lot quicker - to find the information than it is to ask here. Especially as most of the time we have to say "use the debugger to get information" anyway! :laugh:
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
When I changed all loops to start from 0 to n-1,those that start with other number than 0 I set to start from value reduced by 1 to n-1 I still get error: Index was outside the bounds of the array
And? What did the debugger show you?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
And? What did the debugger show you?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
I fixed that error but when I start program and input target value and values I get wrong expression. When I type 100 for target number and numbers 5,8,9,4,20,50 for making expression I get: 5150-(' + w + ')+5355+5150 Instead of: (6-1)*4*5
At the risk of repeating myself:
Quote:
And? What did the debugger show you?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
:-D A quick visit with Mr Debug would have shown the OP as well! :laugh:
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...