阅读背景:

打印时,我的2D数组中有一个缺少的元素

来源:互联网 
#include<stdio.h>
#include<stdlib.h>
#define MSIZE 10
int main()
{
    int Size, gen, i, j;
    printf("Enter number of generations\t");
    scanf("%d", &gen);
    printf("\nEnter size of the matrix (max size is %d and min is 2)\t", MSIZE);
    scanf("%d", &Size);
    if (Size > MSIZE)  {
        printf("\nSize should not be more than %d", MSIZE);
        return 1;
    }
    if (Size < 2)  {
        printf("\nSize should not be less than 2");
        return 1;
    }
    char **m = (char**) calloc(Size, sizeof(char*));
    for (i=0; i<Size; i++)
    {
        m[i] = (char*) calloc(Size, sizeof(char));
    }
    printf("Enter matrix of first generation\n");
    for (i=0; i<Size; i++)  {
        for (j=0; j<Size; j++)  {
            scanf("%c", &m[i][j]);
            /*to make sure*/
            printf("%c ", m[i][j]);
        }
        printf("\n\n");
    }
}
#include<stdio.h>
#include<stdlib.h>
#define MS



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: