#include<stdio.h>
#include<stdlib.h>
void main()
{
char str[100000];
int count,i,len=0,j,num;
scanf("%s",str);
while(str[len++]);
for(i=0;i<len;)
{
int x =(int) (str[i+1]-'0');
int y =(int) (str[i+2]-'0');
if((x<=9)&&(x>=1)&&(y<=9)&&(y>
num= (x*10) +y;
else
num=x;
if(num>=1&&num<=99)
{
for(j=0;j<num;j++)
{
printf("%c",str[i]);
}
}
if(num>=1&&num<=9)
i=i+2;
else
i=i+3;
}
}
#include<stdlib.h>
void main()
{
char str[100000];
int count,i,len=0,j,num;
scanf("%s",str);
while(str[len++]);
for(i=0;i<len;)
{
int x =(int) (str[i+1]-'0');
int y =(int) (str[i+2]-'0');
if((x<=9)&&(x>=1)&&(y<=9)&&(y>
num= (x*10) +y;
else
num=x;
if(num>=1&&num<=99)
{
for(j=0;j<num;j++)
{
printf("%c",str[i]);
}
}
if(num>=1&&num<=9)
i=i+2;
else
i=i+3;
}
}
Thank you raghu konda
ReplyDeleteI want this program as output a2b2c4a2 and input should be aabbccccaa
ReplyDeleteprivate void checkRegex() {
DeleteString regexPattern = "(?<=[0-9])(?=[a-zA-Z])";
String regexPatternInner = "[^a-z]";
String inputStr = "a1b10cc12";
String[] splitStr = inputStr.split(regexPattern);
Log.d("out", String.valueOf(splitStr.length));
String output = "";
for (int i = 0; i < splitStr.length; i++) {
// regex to split
String charString = splitStr[i].split(regexPatternInner)[0];
int repeatCount = Integer.parseInt(splitStr[i].replaceAll("[^0-9]", ""));
for (int j = 0; j < repeatCount; j++) {
System.out.print(charString);
output = output + charString;
}
Log.d("", output);
}
}
Thank you !!!!
ReplyDelete