Day 6 :Lets Review
Solution In Java 8:
import java.io.*;import java.util.*;
public class Solution {
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 s = scan.nextLine();
for(int j = 0;j < s.length() ; j+=2)
{
System.out.print(s.charAt(j));
}
System.out.print(" ");
for(int j = 1;j < s.length() ; j+=2)
{
System.out.print(s.charAt(j));
}
System.out.println();
}
}
}
Solution In Python 3:
n = int (input())
s1 = input()
s2 = input()
for i in range(0,len(s1),2):
print(s1[i],end="")
print(" ",end = "")
for i in range(1,len(s1),2):
print(s1[i],end="")
print("")
for i in range(0,len(s2),2):
print(s2[i],end="")
print(" ",end = "")
for i in range(1,len(s2),2):
print(s2[i],end="")
print("")
Thank you.. This is very helpful. . python Online Course
ReplyDelete