|
|
#1 |
|
Lieutenant
![]() ![]() |
I need to write a program that will do the following:
Given the odd integer as input, it constructs a diamond of '*' characters such that the width of the diamond in characters is exactly equal to the integer input. For example, if the integer entered by the user was 5, the diamond generated would look like the following: * *** ***** *** * If anybody knows how to do this or get me started please e-mail me at surfingking69@yahoo.com. Thanks
__________________
|
|
|
|
|
|
#2 |
|
Commander
![]() ![]() ![]() ![]() ![]() |
is someone looking for help in a programming assignment?
__________________
blurt blurt blurt |
|
|
|
|
|
#3 |
|
Fleet Admiral
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2000
Location: 742 Evergreen Terrace, Springfield USA
Posts: 9,276
|
easy
![]() I could do it if ya need help
__________________
|
|
|
|
|
|
#4 |
|
Fleet Admiral
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2000
Location: 742 Evergreen Terrace, Springfield USA
Posts: 9,276
|
Here ya go
![]() File should be named odd.php <?php IF ($Action == Diamond){ if(!is_long($num/2)){$rtn = 1;} else{Print ("Please enter an odd number"); exit; } while ($i != $num) { $in = 0; $i++; print ("<center>"); while ($in != $i) {print ("*"); $in++;} } $i = $num; while ($i != 0) { $in = 0; $i--; print ("<center>"); while ($in != $i) {print ("*"); $in++;} } } Print (" <html> <body><div align=center> <form method=POST action=odd.php?Action=Diamond> <input type=text name=num size=20> <input type=submit value=Submit name=B1> </form> </body> </html> "); ?> [Edited by hapoo on 05-03-2001 at 12:47 AM] |
|
|
|
|
|
#5 |
|
Lieutenant
![]() ![]() |
thanks alot you saved my ass
|
|
|
|
|
|
#6 |
|
Fleet Admiral
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2000
Location: 742 Evergreen Terrace, Springfield USA
Posts: 9,276
|
ohh ****, i just took a look at your diamond, i didn't realize all the lines had to be odd.
|
|
|
|
|
|
#7 |
|
Admiral
![]() ![]() ![]() ![]() ![]() Join Date: May 2000
Location: Recession Central
Posts: 5,898
|
oops...
looks like SOMEONE just failed their programming class! Hapoo, you know it IS finals period at some schools now? Let's just hope he reads your post BEFORE he runs off to hand it in, hehe ![]() |
|
|
|
|
|
#8 |
|
Fleet Admiral
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2000
Location: 742 Evergreen Terrace, Springfield USA
Posts: 9,276
|
sure hope so!!!
I wrote that in about 15 min (yeah kinda slow but i'm pretty new to php myself), for some reason i didn't see the odd lines. |
|
|
|
|
|
#9 |
|
Admiral
![]() ![]() ![]() ![]() ![]() Join Date: May 2000
Location: Recession Central
Posts: 5,898
|
ok hapoo. It's been 36 hours since PuTangClan's last post where he claimed that you "saved" his ass. I personally am getting a little worried. Let's hope he's not the kind that takes classes too seriously. PuTang...Are you out there?? Can you hear me?? answer if you can please...
damn...Don't worry man. You were just trying to help. You did your best. Think of it this way. If you hadn't helped him, he would have certainly gotten a fat F. Maybe he got some partial credit from your program.... |
|
|
|
|
|
#10 |
|
Lieutenant
![]() ![]() |
I havent turned it in yet, its due next week. I am still trying to figure out a way to change the script so that only odd diamonds are printed out
|
|
|
|
|
|
#11 |
|
Fleet Admiral
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2000
Location: 742 Evergreen Terrace, Springfield USA
Posts: 9,276
|
hehe, want me to do it?
|
|
|
|
|
|
#12 |
|
Fleet Admiral
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2000
Location: 742 Evergreen Terrace, Springfield USA
Posts: 9,276
|
Fixed, I just hope you learn how to do this stuff yourself
<?php IF ($Action == Diamond){ if(!is_long($num/2)){$rtn = 1;} else{Print ("Please enter an odd number"); exit; } $skipline = 0; while ($i != $num) { $in = 0; $i++; if ($skipline == 0) { print ("<center>"); while ($in != $i) {print ("*"); $in++;} $skipline = 1; } else {$skipline = 0;} } $i = $num; while ($i != 0) { $in = 0; $i--; if ($skipline == 0) { print ("<center>"); while ($in != $i) {print ("*"); $in++;} $skipline = 1; } else {$skipline = 0;} } } Print (" <html> <body bgcolor=$Backgroundcolor><div align=center> <form method=POST action=odd.php?Action=Diamond> <input type=text name=num size=20> <input type=submit value=Submit name=B1> </form> </body> </html> "); ?> |
|
|
|
|
|
#13 |
|
Admiral
![]() ![]() ![]() ![]() ![]() Join Date: May 2000
Location: Recession Central
Posts: 5,898
|
Jeez Hapoo!! You're completely ruining this kid! How is he ever gonna learn?!
ahem.... [whisper] You wouldn't happen to know any music history would you? [/whisper] |
|
|
|
|
|
#14 |
|
Lieutenant
![]() ![]() |
thanx
|
|
|
|
|
|
#15 | |
|
Fleet Admiral
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2000
Location: 742 Evergreen Terrace, Springfield USA
Posts: 9,276
|
Quote:
lol sorry, if it doesn't use electricity i can't help you out. |
|
|
|
|