Description: This program performs the transpose of a given Matrix.
Primary Inputs: row no.,column no, element’s value
Primary Output: transpose of a given matrix
Platform Used: Turbo C++ version 3.0, Borland International Inc.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
/*program to find the transpose of a given matrix*/ #include<stdio.h> #include<conio.h> #define max 10. void main() { int x,y,z; int a[max]; int i[max]; int j[max]; printf("\nenter the no. of rows,columns,elements"); scanf("%d%d%d",&x,&y,&z); int k,p,q,r,l; clrscr(); printf("row\t\col\tvalue\n"); printf("%d\t%d\t%d\n",x,y,z); printf("enter the pos and value\n"); printf("row\t\col\tvalue\n"); for(k=0;k<z;k++) scanf("%d\t%d\t%d",&i[k],&j[k],&a[k]); for(k=0;k<z;k++) { p=j[k]; j[k]=i[k]; i[k]=p; } for(k=0;k<z;k++) { for(l=0;l<z;l++) { if(i[k]<i[l]) { p=i[k]; i[k]=i[l]; i[l]=p; q=j[k]; j[k]=j[l]; j[l]=q; r=a[k]; a[k]=a[l]; a[l]=r; } } } printf("\ntranspose of matrix is"); printf("\nrow\tcol\tvalue\n"); printf("%d\t%d\t%d\n",y,x,z); for(k=0;k<z;k++) printf("%d\t%d\t%d\n",i[k],j[k],a[k]); getch(); } |