Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class J02 {
- public static void main(String[] args) {
- Scanner cin = new Scanner(System.in);
- int[] alfabeto = new int[26]; //En java, los valores son 0 por defecto.
- String s = cin.nextLine();
- for(int i=0; i<s.length(); i++) {
- char x = s.charAt(i);
- if('a' <= x && x <= 'z')
- alfabeto[x-'a']++;
- if('A' <= x && x <= 'Z')
- alfabeto[x-'A']++;
- }
- for(int i=0; i<26; i++)
- if(alfabeto[i] > 0)
- System.out.println((char)('a'+i) + ": " + alfabeto[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement