Originally Posted by
john.c
We need more vague descriptions of your code. Perhaps a video of you miming it like in charades.
Or you could just post it here in code tags.
Thanks for replying. this is my code so far :
Code:
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>
int main(){
int sheight = 0, swidth = 0, i1, j1, i2, j2, j3;
while (sheight < 7 || sheight> 79){
printf("Please enter the square height, range 7-79:\n");
scanf("%d", &sheight);
}
while (swidth < 7 || swidth> 79){
printf("Please enter the square width, range 7-79:\n");
scanf("%d", &swidth);
}
//printing 1 or 2 rows of Z's depending on wether height divides by 3 or not.
for (i1 = 1; sheight % 3 == 0 && i1 <= 2; i1++){
for (j1 = 1; j1 <= swidth; j1++){
printf("Z");
}
printf("\n");
}
for (i1 = 1; sheight % 3 != 0 && i1 <= 1; i1++){
for (j1 = 1; j1 <= swidth; j1++){
printf("Z");
}
printf("\n");
}
//printing 1 or 2 columns of Z's depending on wether width divides by 3 or not.
if (swidth % 3 == 0 && sheight % 3 == 0){
for (i2 = 1; i2 <= (sheight - 4); i2++){
printf("ZZ");
//print spaces
for (j2 = 1; j2 <= (swidth - 4); j2++){ printf(" "); }
printf("ZZ\n");
}
//another 2 rows of Z's
for (i1 = 1; sheight % 3 == 0 && i1 <= 2; i1++){
for (j1 = 1; j1 <= swidth; j1++){
printf("Z");
}
printf("\n");
}
}
if (swidth % 3 == 0 && sheight % 3 != 0){
for (i2 = 1; i2 <= (sheight - 2); i2++){
printf("ZZ");
//print spaces
for (j2 = 1; j2 <= (swidth - 4); j2++){ printf(" "); }
printf("ZZ\n");
}
//another row of Z's
for (i1 = 1; sheight % 3 != 0 && i1 <= 1; i1++){
for (j1 = 1; j1 <= swidth; j1++){
printf("Z");
}
printf("\n");
}
}
if (swidth % 3 != 0 && sheight % 3 == 0){
for (i2 = 1; i2 <= (sheight - 4); i2++){
printf("Z");
//print spaces
for (j2 = 1; j2 <= (swidth - 2); j2++){ printf(" "); }
printf("Z\n");
}
//print another 2 rows of Z's
for (i1 = 1; sheight % 3 == 0 && i1 <= 2; i1++){
for (j1 = 1; j1 <= swidth; j1++){
printf("Z");
}
printf("\n");
}
}
if (swidth % 3 != 0 && sheight % 3 != 0){
for (i2 = 1; i2 <= (sheight - 2); i2++){
printf("Z");
//print spaces
for (j2 = 1; j2 <= (swidth - 2); j2++){ printf(" "); }
printf("Z\n");
}
//print another row of Z's
for (i1 = 1; sheight % 3 != 0 && i1 <= 1; i1++){
for (j1 = 1; j1 <= swidth; j1++){
printf("Z");
}
printf("\n");
}
}
return 0;
}
It prints the square's frame according to the given conditions (if height/width divides by 3 double sized top-bottom/ sides is printed), now I should also print the :
XOX
OXO
XOX
inside the square and also make sure that a whole one fits, and not just a part of it, if there's not enough room then the rest should have spaces