Calculating a mode - arrays

I know this is how you calculate a mode for an array of data.
public double mode() {
int maxValue=0, maxCount=0;
for (int i = 0; i < a.length; i++) {
int count = 0;
for (int j = 0; j < a.length; j++) {
if (a[j] == a[i])
++count;
}
}
if (count > maxCount) {
maxCount = count;
maxValue = a[i];
}
}
return maxValue; }
I have a problem when there are multiple values that can be modes. So I want to output (return Double.NaN;) if there are multiple values that are a mode. How do I do that?

Add a condition for when the count is equal:
if (count > maxCount) {
maxCount = count;
maxValue = a[i];
} else if (count == maxCount && maxValue != a[i]) {
maxValue = Double.NaN;
}
Demo (in Javascript): http://jsfiddle.net/Guffa/xWvAV/

Related

Counting number of neighbors Conway's Game of Life

I have an error somewhere in this code.
The number of neighbors is not being counted correctly, as per my understanding. The neighbors function is probably where the issue is. My field variable is a 12x12 char array, the '#' is an alive cell and '-' is a dead one.
I am relatively new to programming and would appreciate some help with this.
int neighbors(int l, int c)
{
int num = 0;
for (int i = -1; i < 2; i++)
{
for (int j = -1; j < 2; j++)
{
if ((l+i < 0 || l+i > 12) && (c+j < 0 || c+j > 12))
{
continue;
}
else if ((i != 0 || j != 0) && field[(l + i)][(c + j)] == '#')
{
num++;
}
}
}
return num;
}
//game logic
void logic()
{
char temp[12][12];
for (int i = 0; i < 12; i++)
{
for (int j = 0; j < 12; j++)
{
temp[i][j] = field[i][j];
}
}
for (int i = 0; i < 12; i++)
{
for (int j = 0; j < 12; j++)
{
if (field[i][j] == '#')
{
if (neighbors(i, j) < 1 || neighbors(i, j) > 3)
{
temp[i][j] = '-';
}
else
{
temp[i][j] = '#';
}
}
if (field[i][j] = '-')
{
if (neighbors(i, j) == 3)
{
temp[i][j] = '#';
}
else
{
temp[i][j] = '-';
}
}
field[i][j] = temp[i][j];
}
}
}
If the array has dimensions 12x12, the maximum index value is 11, hence the test if ((l+i < 0 || l+i > 12) && (c+j < 0 || c+j > 12)) is incorrect. It should be:
if (l+i < 0 || l+i >= 12 || c+j < 0 || c+j >= 12)
continue;
Another major problem is you update field[i][j] = temp[i][j]; inside the update loop: this corrupts the computation for the neighbors of the adjacent cells. You should first compute the whole temp array and update field in a subsequent loop, or with a single call to memcpy().
Furthermore, the standard rules for Conway's Game of Life are somewhat different from your implementation: if (neighbors(i, j) < 1 || neighbors(i, j) > 3) keeps a cell with a single neighbour alive whereas under the standard rules it should die. Change this test to:
if (neighbors(i, j) < 2 || neighbors(i, j) > 3)
temp[i][j] = '-';
Here is a simplified version:
int neighbors(int l, int c) {
int num = 0;
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
if (l+i >= 0 && l+i < 12 && c+j >= 0 && c+j < 12
&& (i != 0 || j != 0) && field[l+i][c+j] == '#') {
num++;
}
}
}
return num;
}
//game logic
void logic() {
char temp[12][12];
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
temp[i][j] = field[i][j];
}
}
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
int nb = neighbors(i, j);
if (nb < 2 || nb > 3) {
temp[i][j] = '-';
} else
if (nb == 3) {
temp[i][j] = '#';
}
}
}
for (int i = 0; i < 12; i++) {
for (int j = 0; j < 12; j++) {
field[i][j] = temp[i][j];
}
}
}

School program tests not covering my code correctly and I'm not sure why

This might be inappropriate but I'm working on a school project in university and we use an automated test service called Web-Cat. When I upload my file (everything is correct as for the filename and method names etc.) the tests throw this at me:
hint: your code/tests do not correctly cover error: Cannot locate behavioral analysis output.
My code looks like this, I can't find any compile errors or anything that would cause such a problem.
#include <stdio.h>
double getPositiveAverage(double array[], int numItems)
{
double average = 0;
int numOfItems = 0;
for (int i = numItems-1; i >= 0; i--)
{
if (array[i] > 0)
{
average = average + array[i];
numOfItems++;
}
}
if (numOfItems == 0) {
return 0;
}
else {
return average / numOfItems;
}
}
int countRangeValues(double array[], int numItems, double count)
{
double countPlus = count + .5;
double countMinus = count - .5;
int counter = 0;
for (int i = numItems-1; i >= 0; i--)
{
if ((array[i] >= countMinus) && (array[i] < countPlus))
{
counter++;
}
}
return counter;
}
double getMaxAbsolute(double array[], int numItems)
{
double max = 0;
for (int i = numItems-1; i >= 0; i--)
{
if (array[i] == max * -1 && array[i] > 0)
{
max = array[i];
}
else if (array[i] < 0)
{
if (max < 0)
{
if ((array[i] * -1) > (max * -1))
{
max = array[i];
}
}
else
{
if ((array[i] * -1) > max)
{
max = array[i];
}
}
}
else
{
if (max < 0)
{
if ((array[i]) > (max * -1))
{
max = array[i];
}
}
else
{
if ((array[i]) > max)
{
max = array[i];
}
}
}
}
return max;
}
int countInverses(int array[], int numItems)
{
int negarray[numItems];
int negItems = 0;
int posarray[numItems];
int posItems = 0;
int counter = 0;
for (int i = numItems-1; i >= 0; i--)
{
if (array[i] < 0)
{
negarray[negItems] = array[i];
negItems++;
}
else if(array[i] > 0)
{
posarray[posItems] = array[i];
posItems++;
}
}
if (posItems == 0 || negItems == 0)
{
return 0;
}
else
{
if (posItems > negItems)
{
for (int i = posItems-1; i >= 0; i--)
{
for (int j = negItems-1; j >= 0; j--)
{
if ((negarray[j]*-1) == posarray[i] && negarray[j] != 0)
{
counter++;
negarray[j] = 0;
posarray[i] = 0;
}
}
}
}
}
return counter;
}
int getMaxCount(double array[], int numItems)
{
return countRangeValue(array, numItems, getMaxAbsolute(array, numItems));
}
If necessary, I can explain the purpose of all of these methods but the test also says "Your program failed before running any tests. Usually this is a compile problem or premature exit problem. Make sure your program compiles and runs before uploading." So I assume its syntax a compiling problem, I just don't know if anything I did would cause something like that.
Candidate problems:
Compilation error #fussel
// return countRangeValue(array, numItems, getMaxAbsolute(array, numItems));
return countRangeValues(array, numItems, getMaxAbsolute(array, numItems));
Missing main() #Bob__.
Variable length arrays are OK #Eric Postpischil in C99 and optionally in C11 yet do not attempt without insuring a positive array size.
int countInverses(int array[], int numItems) {
if (numItems <= 0) {
return 0;
}
int negarray[numItems];
....
Instead of if (posItems > negItems) { I'd expect if (posItems >= negItems) { or maybe even if (1), yet the goal of countInverses() lacks details for deep analysis.
countRangeValues(..., double count) is suspicious with double count. When count is a large value, countPlus == count and countMinus == count. The function always returns 0 as array[i] >= countMinus) && (array[i] < countPlus) is always false.
OP's getMaxAbsolute() looks too convoluted. Suggested alternative:
double getMaxAbsolute(const double array[], int numItems) {
double max = 0.0;
double amax = 0.0;
for (int i = numItems - 1; i >= 0; i--) {
double aelement = fabs(array[i]);
// If greater or the same, favor + over -
if (aelement > amax || (aelement == amax && array[i] > max)) {
max = array[i];
amax = aelement;
}
}
return max;
}

Comparing sorting methods in C

I have to compare these 3 sorting functions (bubble, insertion, and selection), in their worst, best, and the random possible way to sort an array (when talking about the idea of numbers of comparison).
I built and ran the program. The compiler is working, everything seems fine. The problem is that after the cmd window appears, nothing happens. The program is not returning anything (neither 0 (because of return 0) or writing sth in the file). How can I fix it?
#include <stdio.h>
#include <stdlib.h>
int b[11000];
int w[11000];
int r[11000];
int n;
int comp;
int attr;
FILE*f;
//CREAREA SIRURILOR
//best, worst, random
void sir(int n)
{ int i;
for(i=0; i<n; i++)
{
b[i] = i;
r[i] = rand() % n;
w[i] = n-i-1;
}
}
//INSERTION SORT
void insertion (int a[1000])
{
int j, i, index;
comp = 0;
attr = 0;
for (i = 0; i < n; i++)
{
index = a[i];
j = i;
attr+=1;
while ((j > 0) && (a[j-1] > index))
{ comp++;
a[j] = a[j-1];
j = j-1;
attr+=1;
}
while ((j > 0) || (a[j-1] > index))
{ comp++;
}
a[j] = index;
attr++;
}
fprintf(f,"\t%d\t", comp);
fprintf(f,"\t%d\t", attr);
fprintf(f,"\t%d\t", attr+comp);
}
//Selection Sort
void selection (int a[1000])
{
int j, i, min, temp;
comp = 0;
attr = 0;
for (i = 0; i < n-1; i++)
{
min = i;
for (j = i+1; j < n; j++){
comp++;
if (a[j] < a[min])
min = j;
}
temp = a[i];
a[i] = a[min];
a[min] = temp;
attr+=3;
}
fprintf(f,"\t%d\t", comp);
fprintf(f,"\t%d\t", attr);
fprintf(f,"\t%d\t", attr+comp);
}
//Bubble Sort
void bubblesort (int array[2000])
{
int sorted;
int swap,d;
int c;
comp = 0;
attr = 0;
for (c = 0 ; c < ( n - 1 ); c++)
{
for (d = 0; d < n - c - 1; d++)
{
comp++;
if (array[d] > array[d + 1])
{
swap = array[d];
array[d] = array[d + 1];
array[d + 1] = swap;
attr += 3;
}
}
}
fprintf(f,"\t %d\t", comp);
fprintf(f,"\t %d\t", attr);
fprintf(f,"\t%d\t", attr+comp);
}
void InsertionSort()
{
insertion(b);
insertion(r);
insertion(w);
}
void SelectionSort()
{
selection(b);
selection(r);
selection(w);
}
void BubbleSort()
{
bubblesort(b);
bubblesort(r);
bubblesort(w);
}
int main ()
{
f = fopen("iesire.txt","w+");
if(f == NULL)
{
printf("Error!");
exit(-1);
}
fprintf(f,"\n Bubble Sort\t\n");
fprintf(f,"\tBest\t\t\t\t\t\tAverage\t\t\t\t\t\tWorst\t\t\n");
fprintf(f,"\tComparatii\t\tAtribuiri\t\tComp+Atr\t\tComparatii\t\tAtribuiri\t\tComp+Atr\t\tComparatii\t\tAtribuiri\t\tComp+Atr\n");
for (n = 100; n<=10000; n+=500)
{
sir(n);
BubbleSort();
fprintf(f,"\n");
}
fprintf(f,"\n\n Selection Sort\t\n");
fprintf(f,"\tBest\t\t\t\t\t\tAverage\t\t\t\t\t\tWorst\t\t\n");
fprintf(f,"\tComparatii\t\tAtribuiri\t\tComp+Atr\t\tComparatii\t\tAtribuiri\t\tComp+Atr\t\tComparatii\t\tAtribuiri\t\tComp+Atr\n");
for (n = 100; n<=10000; n+=500)
{
sir(n);
InsertionSort();
fprintf(f,"\n");
}
fprintf(f,"\n\n Insertion Sort\t\n");
fprintf(f,"\tBest\t\t\t\t\t\tAverage\t\t\t\t\t\tWorst\t\t\n");
fprintf(f,"\tComparatii\t\tAtribuiri\t\tComp+Atr\t\tComparatii\t\tAtribuiri\t\tComp+Atr\t\tComparatii\t\tAtribuiri\t\tComp+Atr\n");
for (n = 100; n<=10000; n+=500)
{
sir(n);
SelectionSort();
fprintf(f,"\n");
}
fclose(f);
printf(" Result: 'iesire.txt'.");
return 0;
}

Pseudocode into C

how can I rewrite this into C?
for i = 1; i <= N && !quit; i++
{
for j = 1; i <= N && !quit; j++
{
quit = x(i,j) equals y(i,j)
}
}
I've tried something like this
for (i = 1; i >= 1; i++)
{
for j = 1; j >= 1; j++)
{
if (x==y)
printf("Good");
else
continue;
}
}
But I think it's total nonsence and I just can't figure out the right solution. The program shoud count two equations x=a+u*i; y=b+v*j, where I know a, b, u, v and I need (x=y), else repeat until x=y. If it cannot be equal, it would printf("Wrong").
Try this:
for (i=1; i <= N && !quit; i++)
{
for (j=1; j <= N && !quit; j++)
{
if (x==y){
printf("Good");
break;
}
if(j==N && i==N && x!=y){
printf("Wrong");
}
}
}
Take a look at the following code:
unsigned i;
unsigned j;
bool quit = false;
for (i = 1; i <= N && !quit; i++)
{
for (j = 1; j <= N && !quit; j++)
{
if (x[i][j] == y[i][j])
{
quit = true;
}
}
}
I assumed that x and y are global arrays like following:
int x[N+1][N+1] = { 0 };
int y[N+1][N+1] = { 0 };
Rearange your code for your needs.

C algorithm to try out all the possible combinations of 12 knights in a chess board

I have been writing this program that tries to find how to put 12 knights on a chess board so all squares are either taken up by a knight or one of 12 knights can reach them in one move. So far I have created 2 functions: one takes a board with 12 knights and fills all the squares they can reach with 'T' and another that takes a filled chess board and checks if there are left any squares not taken up by a knight nor dominated by it (meaning no knight can reach it in one move).
Now I am dealing with the problem of how can I try out all the possible combinations of knights. My idea is that after every single combination of 12 knights on a board, I will send the board with 12 knights to be filled with 'T's for all the squares they can reach, and then send it to another function to check if all squares are dominated.
Here is my code:
#include <stdio.h>
#include <stdlib.h>
int filling(char array[8][8])
{
int i, j;
for (i = 0;i < 8;i++)
{
for (j = 0; j < 8;j++)
{
if(array[i][j] == 'H')
{
if(i-1>-1 && j+2<8 && array[i-1][j+2]!='H') array[i-1][j+2]='T';
if(i+1<8 && j+2<8 && array[i+1][j+2]!='H') array[i+1][j+2]='T';
if(i-2>-1 && j+1<8 && array[i-2][j+1]!='H') array[i-2][j+1]='T';
if(i+2<8 && j+1<8 && array[i+2][j+1]!='H') array[i+2][j+1]='T';
if(i-2>-1 && j-1>-1 && array[i-2][j-1]!='H') array[i-2][j-1]='T';
if(i+2<8 && j-1>-1 && array[i+2][j-1]!='H') array[i+2][j-1]='T';
if(i-1>-1 && j-2>-1 && array[i-1][j-2]!='H') array[i-1][j-2]='T';
if(i+1<8 && j-2>-1 && array[i+1][j-2]!='H') array[i+1][j-2]='T';
}
}
}
}
int checking(char array[8][8])
{
int i, j;
for(i = 0;i < 8;i++)
{
for(j = 0;j < 8;j++)
{
if(array[i][j] != 'H' && array[i][j] != 'T')
return 0;
}
}
return 1;
}
int main()
{
int i, j;
char board[8][8];
for(i = 0; i < 8; i++)
{
for(j = 0; j < 8; j++)
board[i][j] = '0';
}
// The following lines are here to test if the checking and filling work
/*board[2][1] = 'H';
board[2][2] = 'H';
board[3][2] = 'H';
board[5][2] = 'H';
board[6][2] = 'H';
board[5][3] = 'H';
board[2][4] = 'H';
board[1][5] = 'H';
board[2][5] = 'H';
board[4][5] = 'H';
board[5][5] = 'H';
board[5][6] = 'H'; */
filling(board);
if(checking(board) == 1) printf (" \n Works");
else printf ("\n Doesnt work");
for(i = 0; i < 8; i++)
{
printf("\n");
for(j = 0; j < 8; j++)
printf("%c ", board[i][j]);
}
return 0;
}
What kind of algorithm I could use to try out every combo? Thank you for your answers.
You need these things:
A sorting rule that puts all possible combinations in a well-defined order.
An initialization rule that defines the board's first such combination.
An increment rule that transitions a board from its current combination to the next combination in the well-defined order.
A rule that detects when the board is in the last combination.
Then you just use algorithm 2 to put the board in the first state. Then check with algorithm 4 to see if you're in the last state. If not, use algorithm 3 to go to the next state.
Algorithm 1 is probably the hard one. One simple rule is just to convert the board's position to a binary number with a zero for an empty square and a one for a full square in a well-defined order, say starting from the top left and going across, then moving to the next row.
If you're on decent, or even semi-decent hardware, you've got a 64-bit unsigned integral type available to you. Let's call that uint64_t.
You can store a chessboard with knight positions as a single uint64_t. You can also store a "dominated" mask in the same type. You simply establish a correlation between the 64 bits in the type and the 64 spaces on the chessboard.
Since there are 64 possible locations, you can pre-compute the possible threat masks for each position, storing that as an array of 64 uint64_t values.
You need to set the position of each knight. But you can safely do them in a certain order, so that knight #1 is always the "highest" knight - his bit position is always highest, or lowest, or whatever. So you could write code like this:
for (k0 = 64; k0 > 11; --k0)
for (k1 = k0 - 1; k1 > 10; --k1)
for (k2 = k1 - 1; k2 > 9; --k2)
...
for (k11 = k10 - 1; k11 >= 0; --k11)
/* do stuff */
But that's horrible, because there are a squillion possibilities (squillion = 1573144097507348889600, thanks #jwd!).
That said, the threat mask for each knight can be computed "incrementally" from the masks of the outer knights, so it might be faster to perform all the computations than to try to store/mark/compute the rotations and flips of the board.
Something like this:
for (kXX = kYY - 1; kXX > (11-XX); --kXX) {
threat_XX = threat_YY | pre_computed_threat[kXX];
for (kZZ = KXX - 1; kZZ > (11-ZZ); --kZZ) {
threat_ZZ = threat_XX | pre_computed_threat[kZZ];
The nice thing about this approach is that your objective is total coverage by threats - all 1 bits in the threat_11 map, in other words. You can test just by inverting the bits and comparing with zero.
Well thanks to my questions of today I got myself blocked from asking more until my rep gets better, but for what its worth I managed to solve the problem myself. I had to take 3 positions in each quarter of the board that can only be reached by seperate horses, that way making my 12 for cycles shorter, as they only had to go through specific locations, instead of trying every single of of them. The execution times is just above one second and it finds two different layouts for 12 knights, marking them 'H' and the positions they can reach in one turn 'T'. Here is the code if anyone ever comes to a problem like this:
#include <stdio.h>
#include <stdlib.h>
struct horses
{
int x;
int y;
};
void fill(struct horses arkliai[12], char array[8][8])
{
int i,j;
for(i = 0; i < 8; i++)
{
for(j = 0; j < 8; j++)
array[i][j] = '0';
}
for(i = 0; i < 12; i++)
{
array[arkliai[i].x][arkliai[i].y] = 'H';
}
pildymas(array);
}
void startingpositions(struct horses arkliai[12])
{
int i = 0;
int j = 0;
int a = 0;
for(a = 0; a < 12; a++)
{
if(i > 7)
{
i = 0;
j++;
}
arkliai[a].x = i;
arkliai[a].y = j;
i++;
}
}
void combinacijos(struct horses h[12], char array[8][8])
{
int a,b,c,d,e,f,g,hi,ii,ji,k,l;
for(a = 0; a < 2; a++)
{
if(a == 0)
{
h[0].x = 1;
h[0].y = 2;
}
if(a == 1)
{
h[0].x = 2;
h[0].y = 1;
}
for(b = 0; b < 2; b++)
{
if(b == 0)
{
h[1].x = 5;
h[1].y = 1;
}
if(b == 1)
{
h[1].x = 6;
h[1].y = 2;
}
for(c = 0; c < 2; c++)
{
if(c == 0)
{
h[2].x = 1;
h[2].y = 5;
}
if(c == 1)
{
h[2].x = 2;
h[2].y = 6;
}
for(d = 0; d <2;d++)
{
if(d == 0)
{
h[3].x = 5;
h[3].y = 6;
}
if(d == 1)
{
h[3].x = 6;
h[3].y = 5;
}
for(e = 0; e < 3; e++)
{
if(e == 0)
{
h[4].x = 2;
h[4].y = 0;
}
if(e == 1)
{
h[4].x = 2;
h[4].y = 2;
}
if(e == 2)
{
h[4].x = 1;
h[4].y = 3;
}
for (f = 0; f < 3; f++)
{
if(f == 0)
{
h[5].x = 1;
h[5].y = 4;
}
if(f == 1)
{
h[5].x = 2;
h[5].y = 5;
}
if(f == 2)
{
h[5].x = 2;
h[5].y = 7;
}
for (g = 0; g < 3; g++)
{
if(g == 0)
{
h[6].x = 5;
h[6].y = 7;
}
if(g == 1)
{
h[6].x = 5;
h[6].y = 5;
}
if(g == 2)
{
h[6].x = 6;
h[6].y = 4;
}
for(hi = 0; hi < 3; hi++)
{
if(hi == 0)
{
h[7].x = 5;
h[7].y = 0;
}
if(hi == 1)
{
h[7].x = 5;
h[7].y = 2;
}
if(hi == 2)
{
h[7].x = 6;
h[7].y = 3;
}
for(ii = 0; ii < 4; ii++)
{
if (ii == 0)
{
h[8].x = 3;
h[8].y = 0;
}
if (ii == 1)
{
h[8].x = 3;
h[8].y = 2;
}
if (ii == 2)
{
h[8].x = 0;
h[8].y = 3;
}
if (ii == 3)
{
h[8].x = 2;
h[8].y = 3;
}
for(ji = 0; ji < 4; ji++)
{
if (ji == 0)
{
h[9].x = 3;
h[9].y = 7;
}
if (ji == 1)
{
h[9].x = 3;
h[9].y = 5;
}
if (ji == 2)
{
h[9].x = 2;
h[9].y = 4;
}
if (ji == 3)
{
h[9].x = 0;
h[9].y = 4;
}
for(k = 0; k < 4; k++)
{
if (k == 0)
{
h[10].x = 4;
h[10].y = 7;
}
if (k == 1)
{
h[10].x = 4;
h[10].y = 5;
}
if (k == 2)
{
h[10].x = 5;
h[10].y = 4;
}
if (k == 3)
{
h[10].x = 7;
h[10].y = 4;
}
for(l = 0;l < 64;l++)
{
if(h[11].x == 7)
{
if(h[11].y == 7)
{
h[11].x = 0;
h[11].y = 0;
break;
}
h[11].x = 0;
h[11].y = h[11].y +1;
}
else { h[11].x= h[11].x+1; }
fill(h, array);
}
}
}
}
}
}
}
}
}
}
}
}
}
int pildymas(char array[8][8])
{
int i, j;
for (i = 0;i < 8;i++)
{
for (j = 0; j < 8;j++)
{
if(array[i][j] == 'H')
{
if(i-1>-1 && j+2<8 && array[i-1][j+2]!='H') array[i-1][j+2]='T';
if(i+1<8 && j+2<8 && array[i+1][j+2]!='H') array[i+1][j+2]='T';
if(i-2>-1 && j+1<8 && array[i-2][j+1]!='H') array[i-2][j+1]='T';
if(i+2<8 && j+1<8 && array[i+2][j+1]!='H') array[i+2][j+1]='T';
if(i-2>-1 && j-1>-1 && array[i-2][j-1]!='H') array[i-2][j-1]='T';
if(i+2<8 && j-1>-1 && array[i+2][j-1]!='H') array[i+2][j-1]='T';
if(i-1>-1 && j-2>-1 && array[i-1][j-2]!='H') array[i-1][j-2]='T';
if(i+1<8 && j-2>-1 && array[i+1][j-2]!='H') array[i+1][j-2]='T';
}
}
}
tikrinimas(array);
}
int tikrinimas(char array[8][8])
{
int i, j;
for(i = 0;i < 8;i++)
{
for(j = 0;j < 8;j++)
{
if(array[i][j] != 'H' && array[i][j] != 'T')
return 0;
}
}
printas(array);
}
int printas(char array[8][8])
{
int i,j;
for(j = 0; j <8; j++)
{
printf("\n");
for(i = 0; i <8 ; i++)
printf("%c ", array[i][7-j]);
}
printf("\n");
}
int main()
{
struct horses hr[12];
char board[8][8];
startingpositions(hr);
combinacijos(hr, board);
return 0;
}

Resources