Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        去年关闭。
                                                                                            
                
        
Process border cells of matrix

该程序将仅考虑边框元素。我需要知道如何得出完全相反的结论。

最佳答案

对于所有边框元素,将始终适用以下一种:

(i,j) is in the form of (0,*), (*,0), (N-1, *), (*, N-1)


其中N是矩阵的大小。

int main()
{
    const int N = 5;
    char mat[5][5] = {
        {'a', 'b', 'c', 'd', 'e'},
        {'f', '-', '-', '-', 'g'},
        {'h', '-', '-', '-', 'i'},
        {'j', '-', '-', '-', 'k'},
        {'l', 'm', 'n', 'o', 'p'}
    };

    for (size_t i=1;i<N-1;i++)
    {
        for(size_t j=1;j<N-1;j++)
        {
            printf("%c",mat[i][j]);
        }
        printf("\n");
    }
}

08-16 11:58