Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class anelidos{
- public static void main(String [] args )
- {
- int n;
- String s,temp;
- Scanner sc=new Scanner(System.in);
- n=sc.nextInt();
- while( n>0 && sc.hasNext());
- {
- s=sc.next();
- s=s.substring(0,s.length()-1);
- for(int i=0;i<n;i++)
- {
- temp=s;
- temp=temp.replace('N', 'K');
- temp=temp.replace('A', 'N');
- temp=temp.replace('K', 'A');
- // System.out.println(s);
- s=s+reverse(temp);
- }
- System.out.println(s+"C");
- n=sc.nextInt();
- }
- }
- public static String reverse(String s)
- {
- int left=0,right=s.length()-1;
- char[]a= s.toCharArray();
- char temp;
- while(left<right)
- {
- temp=a[left];
- a[left]=a[right];
- a[left]=temp;
- left++;
- right--;
- }
- return new String(a);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement