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 quali?es 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 }
时间: 2024-10-24 09:43:28

2076 Problem F Quick Brown Fox的相关文章

Quick Brown Fox

Quick Brown Fox时间限制: 1 Sec  内存限制: 128 MB 题目描述 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 re

XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem F. Matrix Game

题目: Problem F. Matrix GameInput file: standard inputOutput file: standard inputTime limit: 1 secondMemory limit: 256 mebibytesAlice and Bob are playing the next game. Both have same matrix N × M filled with digits from 0 to 9.Alice cuts the matrix ve

Problem F: 合唱比赛开始了!

Problem F: 合唱比赛开始了! Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 440  Solved: 201[Submit][Status][Web Board] Description 为迎接计算机科技文化节的到来,我院面向一年级学生举办了一场合唱比赛.邀请了若干位专家担任评委,并为每个参赛队评分.现在,请设计一个程序来展示这个比赛过程. 其中,类 Team描述了参赛队的信息,包括:专业名称.每个专家给该参赛队的评分以及最终得分等.类C

Problem F CodeForces 16E

Description n fish, numbered from 1 to n, live in a lake. Every day right one pair of fish meet, and the probability of each other pair meeting is the same. If two fish with indexes i and j meet, the first will eat up the second with the probability 

Codeforces Gym 100500F Problem F. Door Lock 二分

Problem F. Door LockTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachments Description It was a beautiful night at Yekaterinburg, the sky was crystal clear with no clouds, and the view of the moon and the stars was

实验12:Problem F: 求平均年龄

Home Web Board ProblemSet Standing Status Statistics Problem F: 求平均年龄 Problem F: 求平均年龄 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 720  Solved: 394[Submit][Status][Web Board] Description 定义一个Persons类,用于保存若干个人的姓名(string类型)和年龄(int类型),定义其方法 void addA

ZOJ 4009 And Another Data Structure Problem(ZOJ Monthly, March 2018 Problem F,发现循环节 + 线段树)

题目链接  ZOJ Monthly, March 2018 Problem F 题意很明确 这个模数很奇妙,在$[0, mod)$的所有数满足任意一个数立方$48$次对$mod$取模之后会回到本身. 所以开$48$棵线段树,和一个永久标记.当对某个区间操作时对这个区间加一层永久标记. 即当前我要查找的第$x$层,实际找的是第$up[i] + x$层. 时间复杂度$O(48nlogn)$ #include <bits/stdc++.h> using namespace std; #define

Problem F(数塔)

Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:<br><br>有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?<br><img src=../data/images/2084-1.jpg><br>已经告诉你了,这是个DP的题目,你能AC吗? Input 输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1

UESTC_Eight Puzzle 2015 UESTC Training for Search Algorithm &amp; String&lt;Problem F&gt;

F - Eight Puzzle Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit Status The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sli