Advertisement
Guest User

lancuchy-znakow-zadania1-4

a guest
Nov 23rd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.65 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javaapplication65;
  7.  
  8. import static java.lang.Boolean.TRUE;
  9. import java.util.Scanner;
  10.  
  11. public class JavaApplication65 {
  12.     public static void main(String[] args) {
  13.         /*
  14.         Scanner wprowadz = new Scanner(System.in);
  15.         String x;
  16.         int y, z, numer;
  17.         z = 1;
  18.        
  19.         System.out.print("Wprowadz: ");
  20.         x = wprowadz.nextLine();
  21.         y = x.charAt(x.length()-1);
  22.        
  23.         for(int i=0; i<x.length()-1; i++) {
  24.            
  25.             numer = x.charAt(i);
  26.            
  27.             if (numer==y) {
  28.                 z++;
  29.             }
  30.            
  31.         }
  32.         System.out.println("Ostatni char powtarza sie: " + z + " razy");
  33. */ // ---------------------------------------------------------------- //
  34. /*
  35.         Scanner wprowadz = new Scanner(System.in);
  36.         String x;
  37.         String napis = "";
  38.         int y;
  39.         System.out.print("Wprowadz: ");
  40.         x = wprowadz.nextLine();
  41.        
  42.         for (int i=x.length()-1; i>=0; i--) {
  43.             y = x.charAt(i);
  44.             napis += (char)y;
  45.            
  46.            
  47.     }
  48.        
  49.         System.out.println(napis);
  50.        
  51.         */ // ----------------------------------------------- //
  52.  /*      
  53.         Scanner wprowadz = new Scanner(System.in);
  54.         String x;
  55.         int y = 0;
  56.         int sprawdz = 0;
  57.         int sprawdz2 = 0;
  58.         System.out.print("Wprowadz: ");
  59.         x = wprowadz.nextLine();
  60.        
  61.         for(int i=0; i<(x.length())/2; i++) {
  62.             y = x.charAt(x.length()-1-i);
  63.             if (x.charAt(i) == y){
  64.                 sprawdz += 1;
  65.             } else {
  66.                 sprawdz2 += -1;
  67.             }
  68.                
  69.            
  70.         }
  71.         if (sprawdz>0 && sprawdz2 == 0) {
  72.             System.out.println("TAK");
  73.         } else {
  74.             System.out.println("NIE");
  75.     }
  76. */
  77.     /* ---------------------------------------
  78.         Scanner wprowadz = new Scanner(System.in);
  79.         String x;
  80.         int y = 0;
  81.         int z = 0;
  82.         int suma = 0;
  83.         System.out.print("Wprowadz: ");
  84.         x = wprowadz.nextLine();
  85.        
  86.         for (int i=0; i<x.length(); i++) {
  87.            
  88.            
  89.             if(Character.isDigit(x.charAt(i)) == TRUE) {
  90.                 y = Character.getNumericValue(x.charAt(i));
  91.                 z += y;
  92.             }
  93.            
  94.         }
  95.         System.out.println("Wynik: " + z);
  96.        
  97.     */
  98.    
  99.    
  100.    
  101.  
  102. }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement