Happiness is more than pleasure without pain

你只有非常努力,才能看起来毫不费力

导航

全字母短句

给定一个句子 s, 告诉 Roy 这个句子是不是一个全字母短句。

输入格式

输入只有一行,包含s.

数据约束

s 的长度最多 103 (1|s|103) 
它可能包括空格,小写字母及大写字母。小写字母跟大写字母可以当成同一个字母。

输出格式

如果 s 是全字母短句, 输出 pangram 
否则,输出 not pangram.

样例输入 #1

We promptly judged antique ivory buckles for the next prize    

样例输出 #1

pangram

样例输入 #2

We promptly judged antique ivory buckles for the prize    

样例输出 #2

not pangram

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Pangrams {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String text =in.nextLine();
text.replace(' ', text.charAt(0));
text=text.toLowerCase();
// System.out.println(text);
Map<Character,Integer> map=new HashMap<>();
char[] c=text.toCharArray();
for(int i=0;i<c.length;i++){
Integer j=map.get(c[i]);
if(j==null)j=1;
else j++;
map.put(c[i], j);
}
int res=map.keySet().size();
if(map.containsKey(' ')){

if(res==27){
System.out.println("pangram");
}
else
System.out.println("not pangram");
}
else
if(res==26){
System.out.println("pangram");
}
else
System.out.println("not pangram");

}
}

 

posted on 2015-03-10 18:16  believer  阅读(395)  评论(0)    收藏  举报