Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <windows.h>
- int main( )
- {
- srand(time(NULL));
- SetConsoleOutputCP(CP_UTF8);
- int **ar;
- int i,j,n,*mas;
- n=rand()%5+1;
- ar=(int**)malloc(n*sizeof(int*));
- mas = (int*)malloc(n*sizeof(int));
- for(i = 0; i<n; i++) {
- mas[i]=rand()%5+1;
- ar[i] = (int*)malloc(mas[i]*sizeof(int));
- for(j = 0; j<mas[i]; j++) {
- ar[i][j]=rand()%21-10;
- printf("%d ",ar[i][j]);
- }
- printf("\n");
- free(ar[i]);
- }
- free(ar);
- int *A=(int*)calloc(100,sizeof(int));
- int *B=(int*)malloc(100*sizeof(int));
- printf("указатель на A %p\nуказатель на B %p\n",&A,&B);
- A=(int*)realloc(A,2*sizeof(int));
- B=(int*)realloc(B,0.5*sizeof(int));
- printf("изменённые адреса A %p\nадрес B %p\n",&A,&B);
- A=(int*)realloc(A,0.25*sizeof(int));
- B=(int*)realloc(B,4*sizeof(int));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement