2076 Problem F Quick Brown Fox

题目描述

A pangram is a phrase that includes at least one occurrence of each of the 26 letters, ‘a’. . .‘z’. You’re probably familiar with this one: “The quick brown fox jumps over the lazy dog.”
Your job is to recognize pangrams. For phrases that don’t contain every letter, report what letters are missing. We’ll say that a particular letter occurs in the phrase if it occurs as either upper case or lower case.

输入

Input starts with a line containing an integer 1 ≤ N ≤ 50. The next N lines are each a single phrase,possibly containing upper and lower case letters, spaces, decimal digits and punctuation characters ‘.’,‘,’, ‘?’, ‘!’, ‘’’ and ‘"’. Each phrase contains at least one and no more than 100 characters.

输出

For each input phrase, output “pangram” if it qualifies as a pangram. Otherwise, output the word “missing” followed by a space and then the list of letters that didn’t occur in the phrase. The list of missing letters should be reported in lower case and should be sorted alphabetically.

样例输入

3
The quick brown fox jumps over the lazy dog.
ZYXW, vu TSR Ponm lkj ihgfd CBA.
.,?!’" 92384 abcde FGHIJ

样例输出

pangram
missing eq
missing klmnopqrstuvwxyz

解题心得:
  题目的意思是,输入一行字符(大小写皆可),判断是否为“全字母短句”,是则输出pangram,否则输出missing 加缺少的字母;
  此题为水题,但是我却做了很久,主要原因是写完后一直在找错,结果最后发现输出错了。
  老是犯些低级错误,丢三落四结果导致白白付出很多时间。
代码:
 1 #include <iostream>
 2 #include <cstring>
 3 #include <cstdio>
 4 using namespace std;
 5 int b[30];
 6 
 7 void is(char a_z[],char a){
 8     int ii;
 9     for(ii=0;ii<26;ii++){
10         if(a==a_z[ii]||a==a_z[ii]-32){
11             b[ii]=1;
12         }
13     }
14 }
15 
16 int main()
17 {
18     int n;
19     int j=0;
20     char a[105];
21     char a_z[26];
22     strcpy(a_z,"abcdefghijklmnopqrstuvwxyz");
23     memset(b,0,30*sizeof(int));
24     scanf("%d",&n);
25     getchar();
26     for(int i=0;i<n;i++){
27         j=0;
28         memset(a,'\0',105*sizeof(char));
29         gets(a);
30         for(int i2=0;a[i2]!='\0';i2++){
31             is(a_z,a[i2]);
32         }
33         for(int i3=0;i3<26;i3++){
34             if(b[i3]==0){
35                 j++;
36             }
37         }
38         if(j==0){
39             printf("pangram\n");
40         }
41         else{
42             printf("missing ");
43             for(int j1=0;j1<26;j1++){
44                 if(b[j1]==0){
45                     printf("%c",a_z[j1]); //我把a_z写成了a,结果好久好久都没找出错误来!!
46                 }
47             }
48             printf("\n");
49         }
50         memset(b,0,30*sizeof(int));
51 
52     }
53     int ab;
54     cin>>ab;
55     return 0;
56 }

 

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-09 11:30
找工作7个月,投了7000封,3段世界五百强实习,才有一个offer,牛油们肯定比我强吧
码农索隆:不对不对不对,实习经历这么厉害,简历也没少投,问题出在哪呢
点赞 评论 收藏
分享
点赞 评论 收藏
分享
05-14 20:34
门头沟学院 Java
窝补药贝八股:管他们,乱说,反正又不去,直接说680
点赞 评论 收藏
分享
求offer的大角牛:不吃香菜
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务