In this problem you must delete all lowercase Latin letters '' from the given string.
Algorithm implementation
Read the input string.
getline(cin, s);Add characters that are not '' to the resulting string .
for (i = 0; i < s.length(); i++)
if (s[i] != 'a') res.push_back(s[i]);Print the answer.
cout << res;Java implementation
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
String s = con.nextLine();
String res = "";
for(int i = 0; i < s.length(); i++)
if (s.charAt(i) != 'a') res = res + s.charAt(i);
System.out.printf(res);
con.close();
}
}Java implementation — replace
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
String s = con.nextLine();
s = s.replace("a", "");
System.out.printf(s);
con.close();
}
}Python implementation
Read the input string.
s = input()To remove all letters '' from the string, use the replace() method. It creates a new string by replacing all occurrences of the specified substring with another substring.
: The substring to be replaced.
: The substring to replace it with.
print(s.replace('a', ''))