import java.io.*;
import java.lang.*;
class Ser
{
public static void main(String args[])throws Exception
{
DataInputStream dd= new DataInputStream(System.in);
System.out.println("enter a string ");
String str=dd.readLine();
System.out.println("enter a character");
char ch=(char)System.in.read();
s o =new s();
if(o.extract(str,ch)==true)
o.display();
else
System.out.println("NOT FOUND");
}
}
class s
{
String s2="";
public boolean extract(String str,char ch2)
{
str=str+" ";
String s3="";
boolean b=false;
int i;
for(i=0;i<str.length();i++)
{
char ch= str.charAt(i);
if(ch != ' ')
s3=s3+ch;
else
{
if(s3.charAt(0)==ch2)
{
b=true;
s2=s2+" "+s3;
}
s3="";
}
}
return b;
}
public void display()
{
System.out.println(s2);
}
}
import java.lang.*;
class Ser
{
public static void main(String args[])throws Exception
{
DataInputStream dd= new DataInputStream(System.in);
System.out.println("enter a string ");
String str=dd.readLine();
System.out.println("enter a character");
char ch=(char)System.in.read();
s o =new s();
if(o.extract(str,ch)==true)
o.display();
else
System.out.println("NOT FOUND");
}
}
class s
{
String s2="";
public boolean extract(String str,char ch2)
{
str=str+" ";
String s3="";
boolean b=false;
int i;
for(i=0;i<str.length();i++)
{
char ch= str.charAt(i);
if(ch != ' ')
s3=s3+ch;
else
{
if(s3.charAt(0)==ch2)
{
b=true;
s2=s2+" "+s3;
}
s3="";
}
}
return b;
}
public void display()
{
System.out.println(s2);
}
}
Comments