Computer Science, asked by prabir5570, 7 months ago

Input String Array Write a program that takes as input String arrays and prints the String arrays Input Format The first line contains N, the number of test cases. The N lines after that contain the test cases Each test case starts with k, the number of elements in the array This is followed by k elements of the array Output Format Print each array in a single line Sample Input / Output Input 3 1 hello 5 hello welcome to the codevita 8 there is nothing better than coding agreed ? Output hello hello welcome to the codevita there is nothing better than coding agreed ?

Answers

Answered by Anonymous
0

Answer:

public static void main(String[] args)

{

Scanner scan = new Scanner(System.in);

int T = scan.nextInt();

scan.nextLine();

for(int i=0 ; i<T ; i++)

{

String myString = scan.nextLine();

int evn = 0,

odd = 0,

len = myString.length();

char strE[] = new char[50],

strO[] = new char[50];

for(int j=0 ; j<len ; j++)

{

if(j%2 == 0)

{

strE[evn] = myString.charAt(j);

evn++;

}

if(j%2 == 1)

{

strO[odd] = myString.charAt(j);

odd++;

}

}

System.out.print(strE);

System.out.print(" ");

System.out.println(strO);

}

}

My Output

Hce akr

Rn ak

The Problem

As you can see, my program successfully meets the test case, and other test cases (using custom input) but every time the HackerRank compiler tells me that my program did not meet t

Similar questions