Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication65;
- import static java.lang.Boolean.TRUE;
- import java.util.Scanner;
- public class JavaApplication65 {
- public static void main(String[] args) {
- /*
- Scanner wprowadz = new Scanner(System.in);
- String x;
- int y, z, numer;
- z = 1;
- System.out.print("Wprowadz: ");
- x = wprowadz.nextLine();
- y = x.charAt(x.length()-1);
- for(int i=0; i<x.length()-1; i++) {
- numer = x.charAt(i);
- if (numer==y) {
- z++;
- }
- }
- System.out.println("Ostatni char powtarza sie: " + z + " razy");
- */ // ---------------------------------------------------------------- //
- /*
- Scanner wprowadz = new Scanner(System.in);
- String x;
- String napis = "";
- int y;
- System.out.print("Wprowadz: ");
- x = wprowadz.nextLine();
- for (int i=x.length()-1; i>=0; i--) {
- y = x.charAt(i);
- napis += (char)y;
- }
- System.out.println(napis);
- */ // ----------------------------------------------- //
- /*
- Scanner wprowadz = new Scanner(System.in);
- String x;
- int y = 0;
- int sprawdz = 0;
- int sprawdz2 = 0;
- System.out.print("Wprowadz: ");
- x = wprowadz.nextLine();
- for(int i=0; i<(x.length())/2; i++) {
- y = x.charAt(x.length()-1-i);
- if (x.charAt(i) == y){
- sprawdz += 1;
- } else {
- sprawdz2 += -1;
- }
- }
- if (sprawdz>0 && sprawdz2 == 0) {
- System.out.println("TAK");
- } else {
- System.out.println("NIE");
- }
- */
- /* ---------------------------------------
- Scanner wprowadz = new Scanner(System.in);
- String x;
- int y = 0;
- int z = 0;
- int suma = 0;
- System.out.print("Wprowadz: ");
- x = wprowadz.nextLine();
- for (int i=0; i<x.length(); i++) {
- if(Character.isDigit(x.charAt(i)) == TRUE) {
- y = Character.getNumericValue(x.charAt(i));
- z += y;
- }
- }
- System.out.println("Wynik: " + z);
- */ // ----------------------------------------------
- /*
- Scanner wprowadz = new Scanner(System.in);
- String x;
- int y = 0;
- int z = 0;
- System.out.print("Wprowadz: ");
- x = wprowadz.nextLine();
- for (int i=0; i<x.length(); i++) {
- if (x.charAt(i) == '(') {
- z++;
- }
- if (x.charAt(i) == ')') {
- y++;
- }
- }
- if (z!=y) {
- System.out.println("Niepoprawna liczba nawiasow");
- } else {
- System.out.println("POPRAWNA liczba nawiasow");
- }
- */ // --------------------------------------
- Scanner wprowadz = new Scanner(System.in);
- String x;
- String nowy = "";
- int n = 0;
- int y = 0;
- System.out.print("Wprowadz ciag: ");
- x = wprowadz.nextLine();
- System.out.print("Wprowadz przesuniecie: ");
- n = wprowadz.nextInt();
- for (int i=0; i<x.length(); i++) {
- int charnum = x.charAt(i)+n;
- if(charnum<'a') {
- charnum += 26;
- }
- if(charnum>'z') {
- charnum -= 26;
- }
- char c = (char)charnum;
- nowy += c;
- }
- System.out.print("Wynik szyfru: " + nowy);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement