Sunday, March 18, 2018

Write a Java progarm to input this and print this Input =a2c3z5 Output = aaccczzzzz

/*

Write a Java progarm to input this and print this
Input =a2c3z5
Output = aaccczzzzz

*/

import java.util.*;
class Test
{
public static void main(String[] args)
{
String s="a2c3z5";
String[] s2=s.split("(?<=\\G..)");
for(String s3:s2)
{
char c=s3.charAt(0);
int n=s3.charAt(1)-48;
for(int i=0;i<n;i++)
{
System.out.print(c);
}
}
}
}

Share this

0 Comment to "Write a Java progarm to input this and print this Input =a2c3z5 Output = aaccczzzzz"

Post a Comment