You are viewing a single comment's thread. Return to all comments →
s = s.Replace(" ",""); int length = s.Length; int row = (int)Math.Floor(Math.Sqrt(length)); int col = (int)Math.Ceiling(Math.Sqrt(length)); StringBuilder sb = new StringBuilder(); while((row * col) < length) { if(row>col) { col++; } else { row++; } } char[,] array2D = new char[row, col]; int index = 0; for(int i=0;i<row;i++) { for(int j=0;j<col;j++) { if(index >= length) { break; } else { array2D[i,j] = s[index++]; } } } for(int i=0;i<col;i++) { for(int j=0;j<row;j++) { if(array2D[j,i] >= 'a' && array2D[j,i] <= 'z') { sb.Append(array2D[j,i]); } // Console.Write(array2D[j,i]); } // Console.Write("\n"); sb.Append(' '); } return sb.ToString();
Seems like cookies are disabled on this browser, please enable them to open this website
Encryption
You are viewing a single comment's thread. Return to all comments →
C