首页 > 代码库 > 动态内存

动态内存


int count = 0;//定义数组长度
    printf("请输入数组长度:");
    scanf("%d",&count);
    int *p = malloc(sizeof(int)*count);
    for (int i = 0; i<count; i++) {
        *(p+i) = arc4random()%(count-1+1)+1;
        printf("%d ",*(p+i));
    }j_0015.gif    printf("\n");
    int max = 0;
    for (int i = 0; i<count; i++) {
        if (max<*(p+i)) {
            max = *(p+i);
        }
    }
    printf(" max = %d ",max);