AreWe

Untitled

May 2nd, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. char[] alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  10.  
  11. System.out.println("Въведете дума: ");
  12. String word = scanner.nextLine();
  13.  
  14. char[] wordchar = word.toLowerCase().toCharArray();
  15.  
  16. int lenght = wordchar.length;
  17.  
  18. int[] finalArray = new int[lenght];
  19.  
  20. for(int i=0; i<lenght; i++)
  21. {
  22. for(int j=0; j<alphabet.length; j++)
  23. {
  24. if(wordchar[i] == alphabet[j])
  25. {
  26. finalArray[i] = j+1;
  27. }
  28. }
  29. System.out.print(finalArray[i] + " ");
  30. }
  31. System.out.println();
  32.  
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment