YorKnEz

pb5

Oct 8th, 2022 (edited)
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. struct Joc {
  5. char alb[30], negru[30];
  6. bool tura; // 0 - alb, 1 - negru;
  7. char board[8][8][3] = { 0 };
  8. };
  9.  
  10. char piese[32][5] = {"WPa2", "WPb2", "WPc2", "WPd2", "WPe2", "WPf2", "WPg2",
  11. "WPh2", "WRa1", "WRh1", "WNb1", "WNg1", "WBc1", "WBf1",
  12. "WKd1", "WQe1", "BPa7", "BPb7", "BPc7", "BPd7", "BPe7",
  13. "BPf7", "BPg7", "BPh7", "BRa8", "BRh8", "BNb8", "BNg8",
  14. "BBc8", "BBf8", "BKd8", "BQe8"};
  15.  
  16. int main() {
  17. Joc joc;
  18.  
  19. for (int i = 0; i < 32; i++) {
  20. int l = 7 - (int)(piese[i][3] - '1');
  21. int c = (int)(piese[i][2] - 'a');
  22.  
  23. strncpy(joc.board[l][c], piese[i], 2);
  24. joc.board[l][c][2] = '\0';
  25. }
  26.  
  27. for (int i = 0; i < 8; i++) {
  28. for (int j = 0; j < 8; j++) {
  29. printf("%s ", joc.board[i][j]);
  30. }
  31. printf("\n");
  32. }
  33.  
  34. return 0;
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment