Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- struct Joc {
- char alb[30], negru[30];
- bool tura; // 0 - alb, 1 - negru;
- char board[8][8][3] = { 0 };
- };
- char piese[32][5] = {"WPa2", "WPb2", "WPc2", "WPd2", "WPe2", "WPf2", "WPg2",
- "WPh2", "WRa1", "WRh1", "WNb1", "WNg1", "WBc1", "WBf1",
- "WKd1", "WQe1", "BPa7", "BPb7", "BPc7", "BPd7", "BPe7",
- "BPf7", "BPg7", "BPh7", "BRa8", "BRh8", "BNb8", "BNg8",
- "BBc8", "BBf8", "BKd8", "BQe8"};
- int main() {
- Joc joc;
- for (int i = 0; i < 32; i++) {
- int l = 7 - (int)(piese[i][3] - '1');
- int c = (int)(piese[i][2] - 'a');
- strncpy(joc.board[l][c], piese[i], 2);
- joc.board[l][c][2] = '\0';
- }
- for (int i = 0; i < 8; i++) {
- for (int j = 0; j < 8; j++) {
- printf("%s ", joc.board[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment