#include <stdio.h>
#include <iostream>
int main() {
// dimensions
int N = 74;
int M = 3;
int i, j;
// dynamic allocation
double** ary = new double*[N]; //2d array
for(i = 0; i < N; ++i) //↑
ary[i] = new double[M]; //1d array
for(i=0; i<N; i++){
for(j=0; j<M; j++){
ary[i][j] = i+j;
printf("point[%d][%d] = %.2f \n", i, j, ary[i][j]);
}
}
// free
for(i = 0; i < N; ++i)
delete [] ary[i];
delete [] ary;
return 0;
}
//reffer to [http: codeformatter.blogspot.jp]
dynamic 2d array using double data type
Wednesday, November 30, 2016
loading..
Subscribe to:
Post Comments (Atom)
No comments