下列程式片段執行後,count 的值為何?- int maze[5][5]= { {1, 1, 1, 1, 1},
- {1, 0, 1, 0, 1},
- {1, 1, 0, 0, 1},
- {1, 0, 0, 1, 1},
- {1, 1, 1, 1, 1} };
- int count=0;
- for (int i=1; i<=2; i=i+1) {
- for (int j=1; j<=2; j=j+1) {
- int dir[3][2] = {{-1,0}, {0,1}, {1,0}};
- for (int d=0; d<3; d=d+1) {
- if (maze[i+dir[d][0]][j+dir[d][1]]==1)
- {
- count = count + 1;
- }
- }
- }
- }
複製代碼本帖隱藏的內容需要回復才可以瀏覽 |