Esempio n. 1
0
/*!
 * @brief An entry point of this program
 * @return exit-status
 */
int main(void) {
  uint row, col;
  uint i;
  int **array, **t_array;
  printf("Number of ROW    = ?\b"); scanf("%u", &row);
  printf("Number of COLUMN = ?\b"); scanf("%u", &col);

  array   = alloc_2d_array(row, col);
  t_array = alloc_2d_array(col, row);
  if (array == NULL || t_array == NULL) {
    fputs("Memory allocation error!\n", stderr);
    return EXIT_FAILURE;
  }

  for (i = 0; i < row; i++) {
    uint j;
    for (j = 0; j < col; j++) {
      int tmp;
      scanf("%d", &tmp);
      array[i][j] = tmp;
    }
  }
  puts("");
  puts("Matrix = ");
  show_2d_array((const int *const *)array, row, col);
  puts("============================================================");

  transpose(t_array, (const int *const *)array, row, col);
  puts("Transposed Matrix = ");
  show_2d_array((const int *const *)t_array, col, row);

  free_2d_array(array, row);
  free_2d_array(t_array, row);
  return EXIT_SUCCESS;
}
Esempio n. 2
0
int main(void)
 {
   int sd[10][20];
int __sd_0;
	for(__sd_0=0;__sd_0<10;__sd_0++)
__boundcheck_metadata_store(&sd[__sd_0][0],&sd[__sd_0][20-1]);

   int array1[10];__boundcheck_metadata_store(&array1[0],&array1[10-1]);

   int array2[10]={1,2,3,4,5,6,7,8,9,10};__boundcheck_metadata_store(&array2[0],&array2[10-1]);

   int a[1][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
int __a_0;
	for(__a_0=0;__a_0<1;__a_0++)
__boundcheck_metadata_store(&a[__a_0][0],&a[__a_0][10-1]);

   int b[2][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
                   {11, 12, 13, 14, 15, 16, 17, 18, 19, 20}};
int __b_0;
	for(__b_0=0;__b_0<2;__b_0++)
__boundcheck_metadata_store(&b[__b_0][0],&b[__b_0][10-1]);

   int array5[][10]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
int __array5_0;
	for(__array5_0=0;__array5_0<2;__array5_0++)
__boundcheck_metadata_store(&array5[__array5_0][0],&array5[__array5_0][10-1]);

   int c[3][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
                   {11, 12, 13, 14, 15, 16, 17, 18, 19, 20},
                   {21, 22, 23, 24, 25, 26, 27, 28, 29, 30}};
int __c_0;
	for(__c_0=0;__c_0<3;__c_0++)
__boundcheck_metadata_store(&c[__c_0][0],&c[__c_0][10-1]);

   int array3[2][3][4];
int __array3_0;

int __array3_1;
	for(__array3_0=0;__array3_0<2;__array3_0++)
	for(__array3_1=0;__array3_1<3;__array3_1++)
__boundcheck_metadata_store(&array3[__array3_0][__array3_1][0],&array3[__array3_0][__array3_1][4-1]);

   int array4[2][3][4]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},{{13,14,15,16},{17,18,19,20},{21,22,23,24}}};
int __array4_0;

int __array4_1;
	for(__array4_0=0;__array4_0<2;__array4_0++)
	for(__array4_1=0;__array4_1<3;__array4_1++)
__boundcheck_metadata_store(&array4[__array4_0][__array4_1][0],&array4[__array4_0][__array4_1][4-1]);


   show_2d_array(a, 1);
   show_2d_array(b, 2);
   show_2d_array(c, 3);
   show_3d_array(array4,4);
   printf("%d\n",array1[_RV_insert_check(0,10,40,18,"main",1)]);
   printf("%d\n",a[_RV_insert_check(0,1,41,18,"main",0)][_RV_insert_check(0,10,41,18,"main",4)]);
   return 1;
 }
Esempio n. 3
0
int main(void)
{
    double source[RS][CS] = {
        {1.1, 2.2, 3.3, 4.4, 5.5},
        {6.6, 7.7, 8.8, 9.0, 10.10},
        {11.11, 12.12, 13.13, 14.14, 15.15}
    };
    double source_copy[RS][CS];

    printf("Array 3x5:\n");
    show_2d_array(RS, CS, source);
    putchar('\n');

    copy_2d_array(RS, CS, source, source_copy);
    printf("Copied array 3x5:\n");
    show_2d_array(RS, CS, source_copy);

    return 0;
}
Esempio n. 4
0
int main(void)
 {
   int sd[10][20];
   int array1[10];
   int array2[10]={1,2,3,4,5,6,7,8,9,10};
   int a[1][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
   int b[2][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
                   {11, 12, 13, 14, 15, 16, 17, 18, 19, 20}};
   int array5[][10]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
   int c[3][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
                   {11, 12, 13, 14, 15, 16, 17, 18, 19, 20},
                   {21, 22, 23, 24, 25, 26, 27, 28, 29, 30}};
   int array3[2][3][4];
   int array4[2][3][4]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},{{13,14,15,16},{17,18,19,20},{21,22,23,24}}};

   show_2d_array(a, 1);
   show_2d_array(b, 2);
   show_2d_array(c, 3);
   show_3d_array(array4,4);
   printf("%d\n",array1[1]);
   printf("%d\n",a[0][4]);
   return 1;
 }
Esempio n. 5
0
int main(void)
 {
/*
   int sd[10][20];
//   __boundcheck_metadata_store(&sd[0][0],&sd[0][19]);

   int array1[10];
   int array2[10]={1,2,3,4,5,6,7,8,9,10};
   int a[1][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
*/

   int b[2][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
                   {11, 12, 13, 14, 15, 16, 17, 18, 19, 20}};
	int __b_i;
	for(__b_i=0;__b_i<2;__b_i++)	
	{
		__boundcheck_metadata_store(&b[__RV_i][0],&b[__RV_i][9]);
	}

//	__boundcheck_metadata_store(&b[0][0],&b[1][9]);

/*

   int array5[][10]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
   int c[3][10] = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
                   {11, 12, 13, 14, 15, 16, 17, 18, 19, 20},
                   {21, 22, 23, 24, 25, 26, 27, 28, 29, 30}};
   int array3[2][3][4];
*/
	
   int array4[2][3][4]={{{1,2,3,4},{5,6,7,8},{9,10,11,12}},{{13,14,15,16},{17,18,19,20},{21,22,23,24}}};
	int __array4_i,__array4_j;
	for(__array4_i=0;__array4_i<2;__array4_i++)
		for(__array4_j=0;__array4_j<3;__array4_j++)
			__boundcheck_metadata_store(&array4[__array4_i][__array4_j][0],&array4[__array4_i][__array4_j][3]);

//   show_2d_array(a, 1);
	show_2d_array(b, 2);
//   show_2d_array(c, 3);
//	show_3d_array(array4,4);
   return 1;
 }