### Hexagon not printing out right

Hey guys so i finished my program and i decided to try to improve a few flaws it has, one of which is that when using an odd number my vertical lines match up but not when using an even number.

So i was wondering if someone could point out where im going wrong,
heres my function it works fine other then the alignment problem.

i tried to sort it by checking if the size inputted is odd or even then printing out the lines accordingly, but that dosn't seem to work.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129`` ``````void Vertical(int sizeInput, int type) { //spacer stores spaces to be used to properly space hexagons and add gaps inside them //counter stores number of iterations that have currently passed so inside spaces get placed properly string spacer = " "; int counter =0; fill = "|"; cout << "Type " << type << endl; int rows = 0; for(; rows < size+1;rows++) { if(rows==0) { for(int spaces = 1+size; spaces > rows;spaces--) { cout << spacer; } for(int tops = 0; tops < size;tops++) { cout << "_"; } cout << endl; } else { for(int spaces = 1+size;spaces > rows;spaces--) { cout << spacer; } cout << "/"; for(int stars=0; stars < size + ((rows - 1) * 2);stars++) { //checks if current iteration is even and if type is 4 //if so prints a spacer instead of the filler if(size % 2 == 0) { if(counter % 2 == 0) { cout << spacer; counter++; } else { cout << fill; counter++; } } if(size % 2 != 0) { if(counter % 2 == 0) { cout << fill; counter++; } else { cout << spacer; counter++; } } } cout << "\\"; cout << endl; } } //empties counter value so iteration count is reset counter = 0; for(; rows >= 2; rows--) { if(rows == 2) { for(int spaces = 2+size;spaces > rows;spaces--) { cout << spacer; } cout << "\\"; for(int bottoms = 0;bottoms < size;bottoms++) { cout << "_"; } cout << "/"; cout << endl; } else { for(int spaces = 2+size;spaces > rows;spaces--) { cout << spacer; } cout << "\\"; if(size % 2 == 0) { for(int stars=0; stars < size + ((rows - 2) *2);stars++) { if(counter % 2 == 0) { cout << spacer; counter++; } else { cout << fill; counter++; } } } if(size % 2 != 0) { for(int stars=0; stars < size + ((rows - 2) *2);stars++) { if(counter % 2 == 0) { cout << fill; counter++; } else { cout << spacer; counter++; } } } cout << "/"; cout << endl; } } rows =0; counter = 0; }``````

thanks in advance, also this is my assignment but i've done the actual assignment now im just finetuning it.
Topic archived. No new replies allowed.