1.Title : The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
P A H NA P L S I I GY I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conversion given a number of rows: string convert(string text, int nRows); convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR".2.pseudocode :
1 creat data structure: 2 the given number of rows → nRows; 3 the given text string → s; 4 stringBuffer[] to restore result → sb; 5 set char position index i = 0;row position index j = 0;combing outcome index k = 1; 6 while i < the length of s,then 7 for each j from 0 to (nRows - 1) 8 append the ith char of s to sb[j]; 9 i++;10 end11 for each j from (nRows - 2) to 112 append the ith char of s to sb[j];13 i++;14 end15 end16 //form a united outcome17 for each k from 1 to (nRows - 1)18 append sb[k] to sb[0];19 end20 terminate and output sb[0];