Re: [algogeeks] matix flipping
This question was asked in a Microsoft interview 2 years back. On Mon, Jun 7, 2010 at 8:05 PM, divya jain sweetdivya@gmail.com wrote: let a[n][n] be the input array nd b[][] be the output for(i=0;in;i++) for(j=0;jn;j++) b[i][j]=a[n-j-1][n-i-1] On 7 June 2010 08:26, sharad sharad20073...@gmail.com wrote: write a c routine to flip an nXn matrix about its non major diagnol 3 4 5 6 7 9 1 2 8 Transpose is: 8 9 5 2 7 4 1 6 3 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] matix flipping
#includeiostream using namespace std; int main(){ int a[4][4]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; int i=0,j,n=3,l=0,m=n; j=n; while(i=n){ int i1=i,j1=j,k=0,l=n; for(;kj1;i1++,j1--){ swap(a[k][i1],a[j1][l]); if(i!=0){ swap(a[i1][k],a[l][j1]); } k++; l--; } i++; j--; } for(i=0;i4;i++){ for(j=0;j4;j++){ couta[i][j] ; } coutendl; } return 0; } On Mon, Jun 7, 2010 at 8:26 AM, sharad sharad20073...@gmail.com wrote: write a c routine to flip an nXn matrix about its non major diagnol 3 4 5 6 7 9 1 2 8 Transpose is: 8 9 5 2 7 4 1 6 3 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] matix flipping
@Sharad, 3 4 5 A= 6 7 9 1 2 8 If B[i,j] = A[n-j, n-i] then --- 8 9 5 B = 2 7 4 1 6 3 Mohit Ranjan On Mon, Jun 7, 2010 at 8:26 AM, sharad sharad20073...@gmail.com wrote: write a c routine to flip an nXn matrix about its non major diagnol 3 4 5 6 7 9 1 2 8 Transpose is: 8 9 5 2 7 4 1 6 3 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] matix flipping
let a[n][n] be the input array nd b[][] be the output for(i=0;in;i++) for(j=0;jn;j++) b[i][j]=a[n-j-1][n-i-1] On 7 June 2010 08:26, sharad sharad20073...@gmail.com wrote: write a c routine to flip an nXn matrix about its non major diagnol 3 4 5 6 7 9 1 2 8 Transpose is: 8 9 5 2 7 4 1 6 3 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.