Author Topic: Need Help / Correction in C, NOT C++  (Read 1199 times)

ic3y

  • Committee Member
  • Autococker
  • Posts: 1398
Need Help / Correction in C, NOT C++
« on: May 26, 2009, 02:09:17 PM »
I hope someone can help me.
This is my function:

Code: [Select]
int gewinnpruefung(char matrix[][8], char symbol, int zug_auswahl, int zl)
{
int i, j, tmp;

/* senkrecht */
tmp = 1;
for(j = zl + 1; j < HOEHE && matrix[(zug_auswahl-1)][j] == symbol; ++j, ++tmp);
if(tmp >= GEWONNEN)
return 1;

/* waagerecht */
tmp = 1;
for(i = (zug_auswahl-1) - 1; i >=      0 && matrix[i][zl] == symbol; --i, ++tmp);
for(i = (zug_auswahl-1) + 1; i <  BREITE && matrix[i][zl] == symbol; ++i, ++tmp);
if(tmp >= GEWONNEN)
return 1;

/* diagonal \ */
tmp = 1;
for(i = (zug_auswahl-1) - 1, j = zl - 1; i >=      0 && j >=     0 && matrix[i][j] == symbol; --i, --j, ++tmp);
for(i = (zug_auswahl-1) + 1, j = zl + 1; i <  BREITE && j <  HOEHE && matrix[i][j] == symbol; ++i, ++j, ++tmp);
if(tmp >= GEWONNEN)
return 1;

/* diagonal / */
tmp = 1;
for(i = (zug_auswahl-1) - 1, j = zl + 1; i >=      0 && j <  HOEHE && matrix[i][j] == symbol; --i, ++j, ++tmp);
for(i = (zug_auswahl-1) + 1, j = zl - 1; i <  BREITE && j >=     0 && matrix[i][j] == symbol; ++i, --j, ++tmp);
if(tmp >= GEWONNEN)
return 1;

return 0;
}

I need it for my program, four wins.

Hoehe -> height
gewonnen -> win


Any ideas, if this works?

T3RR0R15T

  • Map Committee
  • Autococker
  • Posts: 2593
Re: Need Help / Correction in C, NOT C++
« Reply #1 on: May 27, 2009, 02:12:44 PM »
no

Eiii

  • Autococker
  • Posts: 4595
Re: Need Help / Correction in C, NOT C++
« Reply #2 on: May 28, 2009, 10:29:13 PM »
What's the problem?

I'm not incredibly familiar with C, but is the last statement in those for loops valid?