Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------
- ZAD 12
- -----------------------------------------------------------
- String.prototype.escapeDiacritics = function()
- {
- return this.replace(/ą/g, 'a').replace(/Ą/g, 'A')
- .replace(/ć/g, 'c').replace(/Ć/g, 'C')
- .replace(/ę/g, 'e').replace(/Ę/g, 'E')
- .replace(/ł/g, 'l').replace(/Ł/g, 'L')
- .replace(/ń/g, 'n').replace(/Ń/g, 'N')
- .replace(/ó/g, 'o').replace(/Ó/g, 'O')
- .replace(/ś/g, 's').replace(/Ś/g, 'S')
- .replace(/ż/g, 'z').replace(/Ż/g, 'Z')
- .replace(/ź/g, 'z').replace(/Ź/g, 'Z');
- }
- // przykładowe wykorzystanie:
- var test = new String("ąźĘŹĆŚół");
- alert(test.escapeDiacritics());
- -----------------------------------------------------------
- ZAD 5
- -----------------------------------------------------------
- String tekst = "kajak";
- // Poniższe polecenie wyświetli liczbę: 5
- System.out.println(tekst.length());
- -----------------------------------------------------------
- ZAD 7
- -----------------------------------------------------------
- String szyfr(String str)
- {
- char x[ ] = str.toCharArray( );
- for( int i=0 ; i!=x.length ; i++)
- {
- int n = x[i];
- n+=3;
- x[i]=(char)n;
- }
- return new String(x);
- }
- rot
- public class Rot13 {
- public static void main(String[] args) {
- String s = args[0];
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
- if (c >= 'a' && c <= 'm') c += 13;
- else if (c >= 'A' && c <= 'M') c += 13;
- else if (c >= 'n' && c <= 'z') c -= 13;
- else if (c >= 'N' && c <= 'Z') c -= 13;
- System.out.print(c);
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement