[Log In ] [New Posts] []
Go Back   GotApex? Forums Forums > General Topics > Need Deals?
User Name
Password

Reply
 
Thread Tools Search this Thread Display Modes
Old 05-02-2001, 12:25 PM   #1
PuTangClan
Lieutenant
 
PuTangClan's Avatar
 
Join Date: Sep 2000
Location: Boston/DC
Posts: 321
Send a message via ICQ to PuTangClan
Lightbulb

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
__________________
PuTangClan is offline   Reply With Quote
Old 05-02-2001, 12:50 PM   #2
ironchef
Commander
 
ironchef's Avatar
 
Join Date: Dec 2000
Location: SF Bay Area
Posts: 1,342
Send a message via ICQ to ironchef Send a message via AIM to ironchef Send a message via MSN to ironchef Send a message via Yahoo to ironchef
is someone looking for help in a programming assignment?
__________________
blurt blurt blurt
ironchef is offline   Reply With Quote
Old 05-02-2001, 11:13 PM   #3
hapoo
Fleet Admiral
 
hapoo's Avatar
 
Join Date: Jan 2000
Location: 742 Evergreen Terrace, Springfield USA
Posts: 9,276
easy
I could do it if ya need help
__________________
hapoo is offline   Reply With Quote
Old 05-03-2001, 01:42 AM   #4
hapoo
Fleet Admiral
 
hapoo's Avatar
 
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]
hapoo is offline   Reply With Quote
Old 05-03-2001, 12:05 PM   #5
PuTangClan
Lieutenant
 
PuTangClan's Avatar
 
Join Date: Sep 2000
Location: Boston/DC
Posts: 321
Send a message via ICQ to PuTangClan
thanks alot you saved my ass
PuTangClan is offline   Reply With Quote
Old 05-03-2001, 02:11 PM   #6
hapoo
Fleet Admiral
 
hapoo's Avatar
 
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.
hapoo is offline   Reply With Quote
Old 05-03-2001, 03:47 PM   #7
ArkiStan
Admiral
 
ArkiStan's Avatar
 
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
ArkiStan is offline   Reply With Quote
Old 05-03-2001, 03:51 PM   #8
hapoo
Fleet Admiral
 
hapoo's Avatar
 
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.
hapoo is offline   Reply With Quote
Old 05-04-2001, 04:54 AM   #9
ArkiStan
Admiral
 
ArkiStan's Avatar
 
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....
ArkiStan is offline   Reply With Quote
Old 05-04-2001, 08:43 AM   #10
PuTangClan
Lieutenant
 
PuTangClan's Avatar
 
Join Date: Sep 2000
Location: Boston/DC
Posts: 321
Send a message via ICQ to PuTangClan
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
PuTangClan is offline   Reply With Quote
Old 05-04-2001, 06:11 PM   #11
hapoo
Fleet Admiral
 
hapoo's Avatar
 
Join Date: Jan 2000
Location: 742 Evergreen Terrace, Springfield USA
Posts: 9,276
hehe, want me to do it?
hapoo is offline   Reply With Quote
Old 05-04-2001, 06:23 PM   #12
hapoo
Fleet Admiral
 
hapoo's Avatar
 
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>
");

?>

hapoo is offline   Reply With Quote
Old 05-05-2001, 12:26 AM   #13
ArkiStan
Admiral
 
ArkiStan's Avatar
 
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]

ArkiStan is offline   Reply With Quote
Old 05-05-2001, 10:00 AM   #14
PuTangClan
Lieutenant
 
PuTangClan's Avatar
 
Join Date: Sep 2000
Location: Boston/DC
Posts: 321
Send a message via ICQ to PuTangClan
thanx
PuTangClan is offline   Reply With Quote
Old 05-05-2001, 05:02 PM   #15
hapoo
Fleet Admiral
 
hapoo's Avatar
 
Join Date: Jan 2000
Location: 742 Evergreen Terrace, Springfield USA
Posts: 9,276
Quote:
Originally posted by ucbstan

[whisper] You wouldn't happen to know any music history would you? [/whisper]

lol sorry, if it doesn't use electricity i can't help you out.
hapoo is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -7. The time now is 11:23 AM.