Get Mystery Box with random crypto!

Albatta, C dasturlash tilida ichki halqalar bilan bo'sh kvadra | Bekzod code 👨‍💻

Albatta, C dasturlash tilida ichki halqalar bilan bo'sh kvadrat shakl yaratish va kvadrat ichidagi romb ichida X shaklini ko'rsatish uchun kod misoli:



#include

int main() {
int size = 10; // change the size of the square by changing this value
int i, j;

// outer loop to create the square shape
for(i = 1; i <= size; i++) {
for(j = 1; j <= size; j++) {
if(i == 1 || i == size || j == 1 || j == size) {
// if it's the first or last row or column, print *
printf("*");
} else {
// otherwise leave it empty
printf(" ");
}
}

// print a new line after each row
printf("\n");
}

// print the X shape inside the rhombus
int middle = size / 2; // calculate the middle point of the square
for(i = 1; i <= size; i++) {
for(j = 1; j <= size; j++) {
if((i == j || j == size-i+1) && i >= middle && j >= middle) {
// if it's on the diagonal from top left to bottom right or from top right to bottom left within the rhombus
printf("X");
} else {
// otherwise leave it empty
printf(" ");
}
}

// print a new line after each row
printf("\n");
}

return 0;
}



Ushbu kod yulduzcha belgisi bilan kvadrat shakl va kvadrat shakl ichidagi ichki romb ichida X shaklini yaratadi. Kvadrat o'lchamini "o'lcham" o'zgaruvchisining qiymatini o'zgartirish orqali o'zgartirishingiz mumkin. Agar sizga qo‘shimcha yordam kerak bo‘lsa, menga xabar bering.