Created
September 1, 2018 12:42
-
-
Save baalajimaestro/63183a3920c9d3de7e0ce25df2ca84eb to your computer and use it in GitHub Desktop.
Simple program In java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class Nekofuri | |
{ | |
public static void main(String[] args)throws IOException | |
{ | |
String str; | |
BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); | |
str=br.readLine(); | |
char[] A=str.toCharArray(); | |
char B[]=new char[A.length]; | |
int ctr=1; | |
char x=A[0]; | |
int i,k=0; | |
for(i=1;i<A.length;i++) | |
{ | |
if(x==A[i]) | |
{ | |
ctr++; | |
} | |
else if(ctr>=1) | |
{ | |
if(ctr%2==1) | |
{ | |
B[k++]=x; | |
} | |
ctr=1; | |
x=A[i]; | |
} | |
} | |
if(ctr%2==1) | |
{ | |
B[k++]=x; | |
} | |
System.out.println(B); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment