Narendrakoli4666
BAN USERimport java.io.*;
class Reverse
{
public static void main(String args[])
{
try
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
String arr[] = str.split(" ");
int len = arr.length;
StringBuffer result = new StringBuffer();
for(int i = len-1 ; i >= 0 ; i--)
{
result = result.append(arr[i]+" ");
}
String res = ""+result;
System.out.println(res);
}
catch(IOException e)
{
System.out.println(e);
}
}
}
import java.io.*;
class StringComplement
{
static String str;
public static void main(String args[]) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
str = br.readLine();
String complementStr = complement(str);
System.out.println("Original String :"+str);
System.out.println("Complemented String :"+complementStr);
}
static String complement(String str)
{
// Take example : 100110
// 1 is replace with only for future reference to 1
String str1 = str.replaceAll("1","2"); //changing all 1's to 2 200220
String str2 = str1.replaceAll("0","1"); //changing all 0's to 1 211221
String str3 = str2.replaceAll("2","0"); // changing all 2's to 0 011001 //final string
return str3;
}
}
c
- Narendrakoli4666 June 09, 2016It can be implemented by using both