2076 Problem F Quick Brown Fox
2016-06-09 20:51
387 查看
题目描述
![](http://exam.upc.edu.cn/upload/image/20160607/20160607222636_44719.jpg)
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 linecontaining 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 加缺少的字母; 此题为水题,但是我却做了很久,主要原因是写完后一直在找错,结果最后发现输出错了。 老是犯些低级错误,丢三落四结果导致白白付出很多时间。 代码:
#include <iostream> #include <cstring> #include <cstdio> using namespace std; int b[30]; void is(char a_z[],char a){ int ii; for(ii=0;ii<26;ii++){ if(a==a_z[ii]||a==a_z[ii]-32){ b[ii]=1; } } } int main() { int n; int j=0; char a[105]; char a_z[26]; strcpy(a_z,"abcdefghijklmnopqrstuvwxyz"); memset(b,0,30*sizeof(int)); scanf("%d",&n); getchar(); for(int i=0;i<n;i++){ j=0; memset(a,'\0',105*sizeof(char)); gets(a); for(int i2=0;a[i2]!='\0';i2++){ is(a_z,a[i2]); } for(int i3=0;i3<26;i3++){ if(b[i3]==0){ j++; } } if(j==0){ printf("pangram\n"); } else{ printf("missing "); for(int j1=0;j1<26;j1++){ if(b[j1]==0){ printf("%c",a_z[j1]); //我把a_z写成了a,结果好久好久都没找出错误来!! } } printf("\n"); } memset(b,0,30*sizeof(int)); } int ab; cin>>ab; return 0; }
相关文章推荐
- 最长递增子序列 (Longest Increasing Subsequence)
- 设计模式:(3)生成器模式 (Builder)
- java-StringBuider与StringBuffer
- UEditor上传配置
- iOS UI 技巧: 视图无法被点击
- NopCommerce源码分析ContainerBuilder builder.Update(container)
- autofac Adding services after container has been built
- hdu 3836 Equivalent Sets【强连通Kosaraju+缩点染色】
- iOS UIAlertController 警告框详解
- iOS开发之int,NSInteger,NSUInteger,NSNumber的使用
- win10 uefi Ubuntu14.04双系统
- ros_arduino_bridge功能包集的使用错误及解决方法总结
- 开启kerberos后,hue管理hbase
- 347. Top K Frequent Elements
- 1007. Maximum Subsequence Sum
- POJ 2457 Part Acquisition【Dij+记录路径】
- EasyUi基础学习(一)—基本组件(上)
- [HDU 5288] OO's Sequence (序列DP)
- iOS AutoLayout: UIView 关联 Xib 不设置 File's Owner
- CodeForces 28c Bath Queue(概率dp)