fork download
  1. import java.util.*;
  2.  
  3. public class Main
  4. {
  5. public static void main(String[] args)
  6. {
  7. Scanner scan = new Scanner(System.in);
  8. String inp = scan.nextLine(), beta = "", newtext="";
  9. char c;
  10. boolean ispresent=false;
  11. for(int i=0; i<inp.length();i++) {
  12. for(int j=0; j<beta.length(); j++) {
  13. if(beta.charAt(j)==inp.charAt(i)) {
  14. ispresent=true;
  15. }
  16. }
  17. if(ispresent==false&&inp.charAt(i)!=' ') {
  18. beta=beta.concat(Character.toString(inp.charAt(i)));
  19. }
  20. else {
  21. ispresent=false;
  22. }
  23. }
  24. for(int i=0; i<26; i++) {
  25. c='a';
  26. c+=i;
  27. for(int j=0; j<beta.length(); j++) {
  28. if(beta.charAt(j)==c) {
  29. ispresent=true;
  30. }
  31. }
  32. if(ispresent==false) {
  33. beta=beta.concat(Character.toString(c));
  34. }
  35. else {
  36. ispresent=false;
  37. }
  38. }
  39. for(int i=0; i<inp.length(); i++) {
  40. if(inp.charAt(i)==' ') {
  41. newtext=newtext.concat(" ");
  42. }
  43. else {
  44. newtext=newtext.concat(Character.toString(beta.charAt(inp.charAt(i)-'a')));
  45. }
  46. }
  47. System.out.println(newtext);
  48. System.out.println(beta);
  49. }
  50. }
Success #stdin #stdout 0.07s 4386816KB
stdin
diana simonyan
stdout
nbdhd qbgjhxdh
diansmoybcefghjklpqrtuvwxz