Skip to content
Snippets Groups Projects
Verified Commit 40bd629a authored by orestis.malaspin's avatar orestis.malaspin
Browse files

added queen example

parent cf5e5fc3
Branches
No related tags found
No related merge requests found
Pipeline #34825 passed
#include <stdio.h>
#include <stdlib.h>
#define NX 8
#define NY 8
int main() {
char tab[NX][NY];
int cx = 4;
int cy = 7;
for (int i = 0; i < NX; ++i) {
for (int j = 0; j < NY; ++j) {
if (i == cy || j == cx) {
tab[i][j] = '*';
} else if (abs(cy - i) == abs(cx - j)) {
tab[i][j] = '*';
} else {
tab[i][j] = ' ';
}
}
}
tab[cy][cx] = 'R';
for (int i = 0; i < NX; ++i) {
for (int j = 0; j < NY; ++j) {
printf("%c ", tab[i][j]);
}
printf("\n");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment