關于for語句省略的
#include <stdio.h>
int main()
{
? ? int arr[3][3] = {{1,2,3},{4,5,6},{7,8,9}};
? ? int i=0;
? ? int j=0;
? ? for(;i<3;i++) {
? ? for(;j<3;j++) {
? ? printf("%d\n",arr[i][j]);
}
}
? ??
? ? return 0; ? ?
}
和
#include <stdio.h>
int main()
{
? ? int arr[3][3] = {{1,2,3},{4,5,6},{7,8,9}};
? ? int i, j;
? ? for(i=0;i<3;i++) {
? ? for(j=0;j<3;j++) {
? ? printf("%d\n",arr[i][j]);
}
}
? ??
? ? return 0; ? ?
}
產生的結果為什么不一樣,前者是1 2 3后者是數組遍歷了,我認為第一種輸出結果應該也是遍歷猜對呀
2016-02-02
第一個代碼中,當進行i=1的循環是j的初值已經是3了