Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- double* alloc_real_table_1D(int lenght)
- {
- double* x=(double*)malloc(sizeof(double)*lenght);
- return x;
- }
- double** alloc_real_table_2D(int M, int N)
- {
- //rzutowanie typu malloca na to przed =
- double** x=(double**)malloc(sizeof(double*)*M);
- for(int i=0; i<M; i++)
- {
- x[i]= (double*)malloc(sizeof(double)*N);
- }
- return x;
- }
- double*** alloc_real_table_3D(int M, int N, int O)
- {
- double*** x= (double***)malloc(sizeof(double**)*M);
- for(int i=0; i<M; i++)
- {
- x[i]= (double**)malloc(sizeof(double*)*N);
- for(int j=0; j<N; j++)
- {
- x[i][j]= (double*)malloc(sizeof(double)*O);
- }
- }
- return x;
- }
- int main()
- {
- double* x=alloc_real_table_1D(5);
- x[3]=5;
- printf("%lf",x[2]);
- alloc_real_table_3D(10,20,30);
- alloc_real_table_2D(10,20);
- free(x);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement