Hey!
I have one problem with sorting matrix. So i want to sort the first row in matrix alphabetically and than copy all the values of other rows to matching char.

Example:

R E D
b g s
a v g
a a

sorting first row, and copy other char to the matching char

D E R
s g b
g v a
a a

Ty for your help!

Recommended Answers

All 2 Replies

So, other than row 4 (aa) it looks as though you exchange columns based on the results of sorting the first row. Is that the effect you're after?

If so, then the swap during the sort needs to be for each row all at the same time.

 swapColumns(matrix, c1, c2)
 {
   for each row in matrix
     swap(matrix[row][c1], matrix[row][c2]);
 }

Ok ty i figure it out. But now im stuck with some problem. I created adfgx coder, but now im stuck at decoder. I dont know how to write the code backwards. It need to take crypted word and than proprelly arranged it into matrix.

Anyone can help me pls?

ty

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.