Posts

Showing posts from March 22, 2021

Shift Characters Upwards

 Shift Characters Upwards  PROBLEM STATEMENT : The program must accept N string values of equal length L and an integer K as the input. The program must perform the following operation K times. - Shift the middle L-2 characters towards the top by one position among the given N string values. Finally, the program must print the N modified string values as the output.  Boundary Condition(s): 2 <= N <= 100  3 <= Length of each string <= 100  1 <= K <= 10^8  Input Format:  The first line contains N.  The next N lines, each contains a string value.  The (N+2)nd line contains K.  Output Format:  The first N lines containing the N modified string values.  Example Input/Output 1: Input: ( ) 5 coding across expert office travel 1 Output: ccrosg axpers effict oravee todinl Explanation:  Here N = 5 and K = 1.  The length of each string is 6.  K = 1: After shifting the middle 4(6-2) chara...

String Matrix to Character Matrix

 String Matrix to Character Matrix  PROBLEM STATEMENT : The program must accept a matrix of size RxC containing only words as the input. All words in the matrix have the same length as 9. The program must form a character matrix of size (R*3)x(C*3) by expanding the each word to a 3*3 character matrix based on the following conditions. - The 1st row of the 3*3 matrix must be formed using the first 3 characters of the word. - The 2nd row of the 3*3 matrix must be formed using the middle 3 characters of the word. - The 3rd row of the 3*3 matrix must be formed using the last 3 characters of the word. Finally, the program must print the character matrix as the output.  Boundary Condition(s):   1 <= R, C <= 50  Input Format:  The first line contains R and C separated by a space.  The next R lines, each contains C words separated by a space.  Output Format:  The first R*3 lines, each contains C*3 characters separated by a space.  Examp...