Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. #include "funkcje.h"
  2. #include <stdio.h>
  3.  
  4. void read(char tab[8][9]) {
  5. FILE *wejscie;
  6. wejscie = fopen("wejscie.txt", "r");
  7. for (int i=0; i<8; i++) {
  8. fscanf(wejscie, "%s", tab[i]);
  9. }
  10. }
  11.  
  12. void change(char wejscie[8][9], char wyjscie[8][8][4][4]) {
  13. int black;
  14. for (int i=0; i < 8; i++){//petla po duzych wierszach
  15. for (int j = 0; j < 8; j++) {//petla po duzych kolumnach
  16. if ((i + j) % 2) {//ustalanie czy pole jest czarne czy biale
  17. black = 0;
  18. }
  19. else {
  20. black = 1;
  21. }
  22.  
  23. if (wejscie[i][j] == '0') {//sprawdza czy pole jest puste
  24. for (int a=0; a < 4; a++) {//wiersze male
  25. for (int b=0; b < 4; b++) {//kolumny male
  26. if (black) {
  27. wyjscie[i][j][a][b] += '#';
  28. }
  29. else {
  30. wyjscie[i][j][a][b] += '&';
  31. }
  32. }
  33. }
  34. }
  35. else {
  36. for (int a=0; a < 4; a++) {//wiersze male
  37. for (int b=0; b < 4; b++) {//kolumny male
  38. if (a == 0 || a == 3 || b == 0 || b == 3) {//rysuje ramke
  39. if (black) {
  40. wyjscie[i][j][a][b] += '#';
  41. }
  42. else {
  43. wyjscie[i][j][a][b] += '&';
  44. }
  45. }
  46. else {//rysuje wnetrze
  47. wyjscie[i][j][a][b] = wejscie[i][j];
  48. }
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
  55.  
  56. void write(char tab[8][8][4][4]) {
  57. for (int i=0; i < 8; i++) {//wiersze duze
  58. for (int a=0; a < 4; a++) {//wiersze male
  59. for (int j=0; j < 8; j++) {//kolumny duze
  60. for (int b = 0; b < 4; b++) {//kolumny male
  61. printf("%c", tab[i][j][a][b]);
  62. }
  63. }
  64. printf("\n");
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement