HAPPY BIRTHDAY TATER!
Sorry guys but that isn t even working the output I'll get is this :
3 same wrong
4
1
3
3
5
2
32767
10
3
And I expect only this :
3 same wrong
I'm going with birthdayguys example, it looks so simple it must work !
Mull over tabstop's post instead of jumping around and don't omit his suggestion in the printf() part:
Code:printf ( "%d same wrong \n", board[i%9] );
Last edited by itCbitC; 08-17-2011 at 12:00 PM.
Your right :
This code is working like expected !Code:#include <stdio.h> int main ( void ) { int board[] = {9, 8, 6, 3, 4, 1, 3, 5, 2}; int pos = 3; int i; for ( i = pos; i < pos+9; i++ ) if (pos == i % 9) continue; else if (board[i % 9] == board[pos]) printf ( "%d same wrong \n", board[i % 9] ); //return true to use in other part of the program return 0; }
I made some errors because I was working to fast I'm only a newbie and need sometime to understand the code preferabel, I use a debugger just to see the values.
The best thing I learned from you guys is how to use modulo in a for loop and why you never use i and only i % 9