Wright a 'C' program for storage representation of 2-D array.
In GW-BASIC, a 2D array can be declared using the DIM statement, specifying the number of rows and columns. For example, DIM A(5, 5) creates a 2D array named A with 6 rows and 6 columns (indexing starts from 0). You can access and manipulate elements using syntax like A(row, column). Here's a simple example: A(1, 1) = 10 assigns the value 10 to the element in the second row and second column of the array.
int main (int argc, char *argv[]) { int i; for (i=0; i<argc; ++i) printf ("%2d: %s\n", i, argv[i]); return 0; }
looda le lo mera
/****************************************** * C Program to print MultiplicationTable * * Author of the Program: M.JAYAKUMAR..* * Date 23 Nov 2006 * * ***************************************/ #include<stdio.h> main() { int i, p=1, table[10]; /* define integres and array */ /* *************************** * Output Formating Begins * ***************************/ for(i=0;i<61;i++) printf("#"); printf("\n# Program to print Multiplication table of any number"); printf("\n# NOTE: To exit type 0 \n"); for(i=0;i<61;i++) printf("#"); /* *************************** * Output Formating ENDS * ***************************/ while(p != 0) { printf("\nWhich table "); scanf("%d",&p); /* takes input from input */ for(i=0;i<10;i++) /* Fills the array */ { if(p==0) /* Stratagy to exit the program Benins */ { printf("Exiting\n"); break; } /* Stratagy to exit the program ends */ table[i]=i+1; /* Fills the array with numbers 1 - 10 */ printf("%2d x %2d = %2d\n", p, table[i], p * table[i]); } } }
Any multi-dimensional array can be flattened into a linear array. For instance,[[1,2,3],[4,5,6],[7,8,9]]can be flattened into[1,2,3,4,5,6,7,8,9].So a solution to your problem (certainly not the most efficient) would be to flatten the 2d array into a linear array, and sort using a traditional sorting algorithm or Arrays.sort. You would then insert the sorted elements back into the 2d array. This would have nlog(n) complexity.An implementation below:public static void sort2d(int[][] arr){int r = arr.length;int c = arr[0].length;int[] flat = new int[r*c];for (int i = 0; i < r; i++)for (int j = 0; j < c; j++)flat[i*c+j] = arr[i][j];Arrays.sort(flat);for (int i = 0; i < flat.length; i++)arr[i/r][i%c] = flat[i];}
1d array contains single row and multiple columns and 2d array contains multiple row and multiple columns. 2d array is a collection of 1d array placed one below another,while 1d array is simple a collection of elements.
algorithm & flowchrt of 2d matrices
In GW-BASIC, a 2D array can be declared using the DIM statement, specifying the number of rows and columns. For example, DIM A(5, 5) creates a 2D array named A with 6 rows and 6 columns (indexing starts from 0). You can access and manipulate elements using syntax like A(row, column). Here's a simple example: A(1, 1) = 10 assigns the value 10 to the element in the second row and second column of the array.
2D array of size 2x8 and 1D array of size 16
int main (int argc, char *argv[]) { int i; for (i=0; i<argc; ++i) printf ("%2d: %s\n", i, argv[i]); return 0; }
looda le lo mera
A net is a 2D representation of a 3D shape
/****************************************** * C Program to print MultiplicationTable * * Author of the Program: M.JAYAKUMAR..* * Date 23 Nov 2006 * * ***************************************/ #include<stdio.h> main() { int i, p=1, table[10]; /* define integres and array */ /* *************************** * Output Formating Begins * ***************************/ for(i=0;i<61;i++) printf("#"); printf("\n# Program to print Multiplication table of any number"); printf("\n# NOTE: To exit type 0 \n"); for(i=0;i<61;i++) printf("#"); /* *************************** * Output Formating ENDS * ***************************/ while(p != 0) { printf("\nWhich table "); scanf("%d",&p); /* takes input from input */ for(i=0;i<10;i++) /* Fills the array */ { if(p==0) /* Stratagy to exit the program Benins */ { printf("Exiting\n"); break; } /* Stratagy to exit the program ends */ table[i]=i+1; /* Fills the array with numbers 1 - 10 */ printf("%2d x %2d = %2d\n", p, table[i], p * table[i]); } } }
if you were to call a function you would write it as: function(array[][], int pretend, double pretend2); arrays will always be passed by reference, not by value.
Map
int main() { int array[3][3]; int i; for(i=0; i <9;i++) { printf("the element is %d\n", array[i/3][i%3]); } return 0; }
The 2D name for an octagonal prism is an octagon. An octagonal prism consists of two parallel octagonal bases connected by rectangular faces, but when referring to its 2D representation, it is simply an octagon.