Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "funkcje.h"
- #include <stdio.h>
- void read(char tab[8][9]) {
- FILE *wejscie;
- wejscie = fopen("wejscie.txt", "r");
- for (int i=0; i<8; i++) {
- fscanf(wejscie, "%s", tab[i]);
- }
- }
- void change(char wejscie[8][9], char wyjscie[8][8][4][4]) {
- int black;
- for (int i=0; i < 8; i++){//petla po duzych wierszach
- for (int j = 0; j < 8; j++) {//petla po duzych kolumnach
- if ((i + j) % 2) {//ustalanie czy pole jest czarne czy biale
- black = 0;
- }
- else {
- black = 1;
- }
- if (wejscie[i][j] == '0') {//sprawdza czy pole jest puste
- for (int a=0; a < 4; a++) {//wiersze male
- for (int b=0; b < 4; b++) {//kolumny male
- if (black) {
- wyjscie[i][j][a][b] += '#';
- }
- else {
- wyjscie[i][j][a][b] += '&';
- }
- }
- }
- }
- else {
- for (int a=0; a < 4; a++) {//wiersze male
- for (int b=0; b < 4; b++) {//kolumny male
- if (a == 0 || a == 3 || b == 0 || b == 3) {//rysuje ramke
- if (black) {
- wyjscie[i][j][a][b] += '#';
- }
- else {
- wyjscie[i][j][a][b] += '&';
- }
- }
- else {//rysuje wnetrze
- wyjscie[i][j][a][b] = wejscie[i][j];
- }
- }
- }
- }
- }
- }
- }
- void write(char tab[8][8][4][4]) {
- for (int i=0; i < 8; i++) {//wiersze duze
- for (int a=0; a < 4; a++) {//wiersze male
- for (int j=0; j < 8; j++) {//kolumny duze
- for (int b = 0; b < 4; b++) {//kolumny male
- printf("%c", tab[i][j][a][b]);
- }
- }
- printf("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement