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 }

 

转载于:https://www.cnblogs.com/TWS-YIFEI/p/5572711.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值