Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- 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'};
- System.out.println("Въведете дума: ");
- String word = scanner.nextLine();
- char[] wordchar = word.toLowerCase().toCharArray();
- int lenght = wordchar.length;
- int[] finalArray = new int[lenght];
- for(int i=0; i<lenght; i++)
- {
- for(int j=0; j<alphabet.length; j++)
- {
- if(wordchar[i] == alphabet[j])
- {
- finalArray[i] = j+1;
- }
- }
- System.out.print(finalArray[i] + " ");
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment