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.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.util.StringTokenizer; | |
public class Addrev { | |
public static void main(String[] args)throws Exception { | |
BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); | |
int count = Integer.parseInt(in.readLine()); |
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.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.util.StringTokenizer; | |
import java.util.Vector; | |
import static java.lang.Math.floor; | |
import static java.lang.Math.sqrt; | |
public class Prime { |
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
//Given a string, return a new string where the first and last chars have been exchanged. | |
public String frontBack(String str) { | |
int n=str.length(); | |
if(n>=2){ | |
return str.substring(n-1)+str.substring(1,n-1)+str.substring(0,1); | |
} | |
else | |
return str; | |