Alternate X Characters
JAVA Code :-
import java.util.*;
public class Hello {
public static void main(String[] args) {
//Your Code Here
Scanner s=new Scanner(System.in);
String str=s.nextLine();
int n=s.nextInt(),l=str.length(),g=0;
for(int i=0;i<l;i++)
{
if(g<n)
{
System.out.print(str.charAt(i));
g++;
}
else
{
i+=n-1;
g=0;
}
}
}
}
public class Hello {
public static void main(String[] args) {
//Your Code Here
Scanner s=new Scanner(System.in);
String str=s.nextLine();
int n=s.nextInt(),l=str.length(),g=0;
for(int i=0;i<l;i++)
{
if(g<n)
{
System.out.print(str.charAt(i));
g++;
}
else
{
i+=n-1;
g=0;
}
}
}
}
Comments
Post a Comment