the program will find the matched numbers and should show "nil" when any number matched in that array.Code:#include <stdio.h> int main() { int i, j, k, match, tmp[4] = {4, 12, 25, 30}; int num[4][4] = { {34, 55, 125, 55}, {4, 515, 25, 11},{34, 5, 12, 65},{24, 15, 625, 35}}; for(i=0;i<4;i++){ printf("The matched numbers of row %d are:\n", i+1); for(j=0;j<4;j++){ for(k=0;k<4;k++) if(num[i][j]==tmp[k]) printf("%4d", tmp[k]); match = match + 1; } if(match = 0) printf("nil"); printf("\n");} system("pause"); return 0; }
the output should be:
the problem now is that when there isn't any numbers matched, the "nil" doesn't appear....Code:the matched numbers of row 1 are: nil the matched numbers of row 2 are: 4 25 ...etc
why?



LinkBack URL
About LinkBacks



