Advertisement
kanciastopantalones

MPZ

Dec 6th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. -----------------------------------------------------------
  2. ZAD 12
  3. -----------------------------------------------------------
  4.  
  5. String.prototype.escapeDiacritics = function()
  6. {
  7. return this.replace(/ą/g, 'a').replace(/Ą/g, 'A')
  8. .replace(/ć/g, 'c').replace(/Ć/g, 'C')
  9. .replace(/ę/g, 'e').replace(/Ę/g, 'E')
  10. .replace(/ł/g, 'l').replace(/Ł/g, 'L')
  11. .replace(/ń/g, 'n').replace(/Ń/g, 'N')
  12. .replace(/ó/g, 'o').replace(/Ó/g, 'O')
  13. .replace(/ś/g, 's').replace(/Ś/g, 'S')
  14. .replace(/ż/g, 'z').replace(/Ż/g, 'Z')
  15. .replace(/ź/g, 'z').replace(/Ź/g, 'Z');
  16. }
  17. // przykładowe wykorzystanie:
  18. var test = new String("ąźĘŹĆŚół");
  19. alert(test.escapeDiacritics());
  20.  
  21. -----------------------------------------------------------
  22. ZAD 5
  23. -----------------------------------------------------------
  24.  
  25. String tekst = "kajak";
  26. // Poniższe polecenie wyświetli liczbę: 5
  27. System.out.println(tekst.length());
  28.  
  29.  
  30. -----------------------------------------------------------
  31. ZAD 7
  32. -----------------------------------------------------------
  33.  
  34.  
  35. String szyfr(String str)
  36. {
  37. char x[ ] = str.toCharArray( );
  38.  
  39. for( int i=0 ; i!=x.length ; i++)
  40. {
  41. int n = x[i];
  42. n+=3;
  43. x[i]=(char)n;
  44. }
  45. return new String(x);
  46. }
  47.  
  48.  
  49.  
  50.  
  51. rot
  52.  
  53.  
  54. public class Rot13 {
  55.  
  56. public static void main(String[] args) {
  57. String s = args[0];
  58. for (int i = 0; i < s.length(); i++) {
  59. char c = s.charAt(i);
  60. if (c >= 'a' && c <= 'm') c += 13;
  61. else if (c >= 'A' && c <= 'M') c += 13;
  62. else if (c >= 'n' && c <= 'z') c -= 13;
  63. else if (c >= 'N' && c <= 'Z') c -= 13;
  64. System.out.print(c);
  65. }
  66. System.out.println();
  67. }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement