monkeyslut45

Кирилл Деменев

Dec 3rd, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4. import java.util.Random;
  5.  
  6. public class Main {
  7.     public static int everything(String smth, String smth2) {
  8.         int k = 0;
  9.         StringBuilder str = new StringBuilder();
  10.         str.append(smth);
  11.         StringBuilder str2 = new StringBuilder();
  12.         str2.append(smth2);
  13.         for (int i = 0; i < str.length(); i++) {
  14.             if (smth.charAt(i) == smth2.charAt(0)) {
  15.                 for (int j = 0; j < str2.length(); j++) {
  16.                     if (smth.charAt(i) == smth2.charAt(j)) {
  17.  
  18.                     }
  19.                     else {
  20.                         break;
  21.                     }
  22.                     k++;
  23.                 }
  24.             }
  25.         }
  26.         return k;
  27.     }
  28.  
  29.     public static void main(String[] args) {
  30.         Scanner in = new Scanner(System.in);
  31.         String str = in.nextLine();
  32.         String str2 = in.nextLine();
  33.         System.out.println(everything(str, str2));
  34.     }
  35. }
Add Comment
Please, Sign In to add comment