දෙන ලද String input එකක් encode කරමු


--- Code ---

import java.util.*;
class Demo{
public static void main(String args[]){
String word="dddffffsssfffggggg";
System.out.print("Input : "+word+"\nOutput : ");

char t='?';
int count=0;

for (int i = 0; i < word.length(); i++){
if (t!=word.charAt(i)){
t=word.charAt(i);
count++;
}
}

String letter[]=new String[count];
char t1='?';
int countStringArray=0;

for (int i = 0; i < word.length(); i++){
if (t1!=word.charAt(i)){
t1=word.charAt(i);
letter[countStringArray]=t1+"";
countStringArray++;
}
}

int countLetter[]=new int[count];
char t2=word.charAt(0);
int countNoOfChar=0;
int countIntArray=0;

for (int i = 0; i < word.length(); i++){
if (t2==word.charAt(i)){
countNoOfChar++;
}else{
countLetter[countIntArray]=countNoOfChar;
countIntArray++;
t2=word.charAt(i);
countNoOfChar=1;
}
if (i==word.length()-1)
{
countLetter[countIntArray]=countNoOfChar;
}
}


for (int i = 0; i < letter.length; i++)
{
System.out.print(letter[i]+""+countLetter[i]);
}

}
}



මෙවැනි තොරතුරු දිනපතා දැනගන්න, අපේ YouTube Channel එක Subscribe කරලා තියාගන්න.



Our Socials
Facebook
Twitter