You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Schar {
public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ int tp,l,n; Scanner sc=new Scanner(System.in); l=sc.nextInt(); String s=sc.next(); n=sc.nextInt(); char u[]=s.toCharArray(); char []sn=new char[l]; for(int i=0;i<l;i++) { if(u[i]<='z' & u[i]>='a') { tp=(int)u[i]+n; for(int j=1;(tp>122 | tp<97);j++) tp=tp-26; sn[i]=(char)tp; } else if(u[i]<='Z' & u[i]>='A') { tp=(int)u[i]+n; for(int j=1;(tp>90 | tp<65);j++) tp=tp-26; sn[i]=(char)tp; } else sn[i]=u[i]; } String f=new String(sn); System.out.println(f); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Schar {
}