第二题似乎不用考虑那么多,这俩for循环就ac了 for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(matrix[i][j]==0) { ret++;i++ } } }