soooo who wants to help me figure out my D shortcomings
Tori
rshenely at yahoo.com
Thu May 30 21:39:43 PDT 2013
/* licenced under the wtfpl license :D... as if i even understand
how to license*/
import std.stdio;
void main(){
//yeah... im making a diamond pattern out off asterisks
writeln("Pick a number that is odd");
int chosen;
bool oddnoteven = false;
while(oddnoteven == false){
write("Enter number here: ");
readf(" %s", &chosen);
int numbercheck = chosen % 2;
if(numbercheck == 0){
writeln("I really don't like even numbers mofo >:/... Just odd
ones.. Try again? :D");
}
else{
oddnoteven = true;
}
}
int peak = (chosen + 1)/2;
for(int counter = 0; counter < chosen + 1; ++counter){ // this
is my fro block.
//Ok its not broken DO NOT KILL THE BLOCK!!!!!
if(counter < peak){
int spacesneeded = (peak - counter) - 1;
for(int spacesmade = 0 ; spacesmade < spacesneeded;
++spacesmade ){
write(" ");
}
int shotsneeded = (2*counter) + 1;//(countxXXXerx + 1) +x
(counterx + 1)/xxxxx2; uhh nope
for(int shotsmade = 0; shotsmade < shotsneeded; ++shotsmade){
write("*");
}
writeln();
}
//hmmm bastard block... >:/
if(counter > peak){
int spacesneeded = (counter - peak);
for(int spacesmade = 0; spacesmade < spacesneeded;
++spacesmade){
write(" ");
}
int shotsneeded = (2*(chosen - counter))+ 1;
for(int shotsfired = 0; shotsfired < shotsneeded;
++shotsfired){
write("*");
}
writeln();
}
}
}
so this prog is supposed to take an odd num and ouput some
diamond shape in le terminal. sooo i know it may not be the best
specim in ze world but i gotta know why the gnarly fakk i had to
add "+1" to "chosen" for the standard stacker, it just cuts off
the last print of my asterik on my bastard block if i dont have
the "+1" setup. enlighten me please :D
More information about the Digitalmars-d
mailing list