Chaos 1,427 Posted February 10, 2016 Report Share Posted February 10, 2016 I need to make a loop pattern program with the output as * * * * * * * * * Too much space in between lines sry ;_; But I'm pretty sure I conveyed this well. So help? Quote Link to post Share on other sites
Shawnic 2,977 Posted February 10, 2016 Report Share Posted February 10, 2016 Hmm... that shouldn't be too difficult (you want just those *s, right?) Quote Link to post Share on other sites
Chaos 1,427 Posted February 10, 2016 Author Report Share Posted February 10, 2016 38 minutes ago, Master Flap said: Hmm... that shouldn't be too difficult (you want just those *s, right?) Using a loop statement. Need to increment the number of asterisks and then decrement it to 1. Quote Link to post Share on other sites
Echo 746 Posted February 10, 2016 Report Share Posted February 10, 2016 Use a for loop within a for loop. The inner loop prints the number of asterisks in the row, then the outer loop moves everything to the next line. Run that double loop for the intended length of the pattern (number of lines it runs), divided by two. Then have another double loop with does the same thing but just counts down asterisks instead of up. Quote Link to post Share on other sites
Chaos 1,427 Posted February 10, 2016 Author Report Share Posted February 10, 2016 10 minutes ago, FOX545 said: Use a for loop within a for loop. The inner loop prints the number of asterisks in the row, then the outer loop moves everything to the next line. Run that double loop for the intended length of the pattern (number of lines it runs), divided by two. Then have another double loop with does the same thing but just counts down asterisks instead of up. Yeah that was kinda obvious, but I'm just not getting it right. I've been trying over and over again and just don't know where I'm going wrong. Quote Link to post Share on other sites
Echo 746 Posted February 11, 2016 Report Share Posted February 11, 2016 (edited) 5 hours ago, Chaos said: Yeah that was kinda obvious, but I'm just not getting it right. I've been trying over and over again and just don't know where I'm going wrong. Try using the debugger if your IDE has one If not you could just copy your code here and we could try to help Edited February 11, 2016 by FOX545 Quote Link to post Share on other sites
Chaos 1,427 Posted February 11, 2016 Author Report Share Posted February 11, 2016 42 minutes ago, FOX545 said: Try using the debugger if your IDE has one If not you could just copy your code here and we could try to help I'll do that in a while. Quote Link to post Share on other sites
Conan Edogawa 837 Posted February 12, 2016 Report Share Posted February 12, 2016 23 hours ago, Chaos said: I'll do that in a while. So we can examine what you might be expressing. Quote Link to post Share on other sites
Shawnic 2,977 Posted February 12, 2016 Report Share Posted February 12, 2016 On 2/11/2016 at 8:02 AM, Chaos said: I'll do that in a while. No, I think for loops would suffice. 2 Quote Link to post Share on other sites
Chaos 1,427 Posted February 12, 2016 Author Report Share Posted February 12, 2016 Ok nvm I got that. Someone explain Binary search to me instead plox Quote Link to post Share on other sites
Shawnic 2,977 Posted February 12, 2016 Report Share Posted February 12, 2016 2 minutes ago, Chaos said: Ok nvm I got that. Someone explain Binary search to me instead plox Binary search is a common but very powerful algorithm used to increase the efficiency of your programs. To have an idea of how binary search works, think of it in this way: Suppose you were asked to think of a number between 0-100 and I had to guess what number you had. If I used the binary method, I'd guess 50. Then you'd tell me whether I'm right or if I'm guessing too high or too low. If I'm right, I'll stop and say 50 is the right answer. If I'm too high, I'll limit my guesses from 0 to 49. If I'm too low, it'll reduce to 51-100. You keep going till you get the right answer. You can see that this reduces the number of guesses drastically. Quote Link to post Share on other sites
Chaos 1,427 Posted February 12, 2016 Author Report Share Posted February 12, 2016 3 minutes ago, Master Flap said: Binary search is a common but very powerful algorithm used to increase the efficiency of your programs. To have an idea of how binary search works, think of it in this way: Suppose you were asked to think of a number between 0-100 and I had to guess what number you had. If I used the binary method, I'd guess 50. Then you'd tell me whether I'm right or if I'm guessing too high or too low. If I'm right, I'll stop and say 50 is the right answer. If I'm too high, I'll limit my guesses from 0 to 49. If I'm too low, it'll reduce to 51-100. You keep going till you get the right answer. You can see that this reduces the number of guesses drastically. Any programs to serve as examples? Quote Link to post Share on other sites
Shawnic 2,977 Posted February 12, 2016 Report Share Posted February 12, 2016 1 minute ago, Chaos said: Any programs to serve as examples? Tons. Many programs use it. Using a slightly modified version of it, there are programs that find square roots of numbers. Other examples are of course, guessing games. 1 Quote Link to post Share on other sites
Jade Maveric 26 Posted February 14, 2016 Report Share Posted February 14, 2016 Try the binary search tutorial on KhanAcademy. And can someone please clarify, are links allowed? Quote Link to post Share on other sites
test 367 Posted February 14, 2016 Report Share Posted February 14, 2016 (edited) 48 minutes ago, Jade Maveric said: Try the binary search tutorial on KhanAcademy. And can someone please clarify, are links allowed? They are, unless they conflict with the rules (there is no longer an external link rule). The only rule that can by bypassed somehow is swearing, which can be done in PM if both parties are comfortable with it and you could post a video or link with swearing in it, making sure to warn the viewers. Or at least that is what I believe. Edited February 14, 2016 by Chocozeus Italicizing Quote Link to post Share on other sites
Agent P 2,480 Posted April 14, 2017 Report Share Posted April 14, 2017 I did this exact pattern last November oh Quote Link to post Share on other sites
Agent P 2,480 Posted December 29, 2017 Report Share Posted December 29, 2017 On 2/12/2016 at 0:55 PM, Master Flap said: Tons. Many programs use it. Using a slightly modified version of it, there are programs that find square roots of numbers. Other examples are of course, guessing games. can you send me a link of those programs? That sounds interesting. Quote Link to post Share on other sites
Shawnic 2,977 Posted December 29, 2017 Report Share Posted December 29, 2017 1 hour ago, Agent P said: can you send me a link of those programs? That sounds interesting. I'll search for it. Though I've only seen it on a friend's computer once. Wow, wasn't hard to find it. https://www.geeksforgeeks.org/square-root-of-an-integer/ I haven't checked it thoroughly but that's what I was talking about. Quote Link to post Share on other sites
Agent P 2,480 Posted December 30, 2017 Report Share Posted December 30, 2017 18 hours ago, Master Flap said: I'll search for it. Though I've only seen it on a friend's computer once. Wow, wasn't hard to find it. https://www.geeksforgeeks.org/square-root-of-an-integer/ I haven't checked it thoroughly but that's what I was talking about. Ohhh it's like a Brute Force Method of sorts. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.