Sunday 19 October 2014

Print Subarray

Level: Easy

Given an input character array of A and start index S and end index E, write a function that prints the sub array starting from S (including S) and ending at index E (including E). The character array may contain spaces and tabs.
Note: You are given the main function. Just write the subroutine 'void printSubarray(char *a, int start, int end)'. 

Input Format:
First line is the input array A s.t. 1 <= |A| <= 8192
Second line is the start index S s.t. 0 <= S <= |A|-1
Third line is the ending index E s.t. 0 <= E <= |A|-1



Output Format:
A single line containing the sub array of A from start index S to end index E. 




void printSubarray(char *array,int start,int end)
{int i;
for(i=start;i<=end;i++)
{
printf("%c",array[i]);
}

}

No comments:

Post a Comment