Extra Krunch
来源:互联网 发布:四川理工学院网络教学 编辑:程序博客网 时间:2024/05/20 06:38
Description
A krunched word has no vowels ("A", "E", "I", "O", and "U") and no repeated letters. Removing vowels and letters that appear twice or more from MISSISSIPPI yields MSP. In a krunched word, a letter appears only once, the first time it would appear in the unkrunched word. Vowels never appear.
Krunched phrases similarly have no vowels and no repeated letters. Consider this phrase:
and its krunched version:
Blanks are krunched differently. Blanks are removed so that a krunched phrase has no blanks on its beginning or end, never has two blanks in a row, and has no blanks before punctuation. Otherwise, blanks not removed. If we represent blanks by "_",
krunches to:
where the single remaining blank is shown by "_".
Write a program that reads a line of input (whose length ranges from 2 to 70 characters), and krunches it. Put the krunched word or phrase in the output file. The input line has only capital letters, blanks, and the standard punctuation marks: period, comma, and question mark.
Krunched phrases similarly have no vowels and no repeated letters. Consider this phrase:
RAILROAD CROSSING
and its krunched version:
RLD CSNG
Blanks are krunched differently. Blanks are removed so that a krunched phrase has no blanks on its beginning or end, never has two blanks in a row, and has no blanks before punctuation. Otherwise, blanks not removed. If we represent blanks by "_",
MADAM_I_SAY_I_AM_ADAM__
krunches to:
MD_SY
where the single remaining blank is shown by "_".
Write a program that reads a line of input (whose length ranges from 2 to 70 characters), and krunches it. Put the krunched word or phrase in the output file. The input line has only capital letters, blanks, and the standard punctuation marks: period, comma, and question mark.
Input
A single line to be krunched.
Output
A single krunched line that follows the rules above.
题意:给出一个只含大写字母,空格 ,逗号,句号,问号的字符串,最后输出的字符串首尾不能有空格,不能有连续的空格,不能有元音字母,字母只能出现一次,标点符号前面不可以空格
Sample Input
NOW IS THE TIME FOR ALL GOOD MEN TO COME TO THE AID OF THEIR COUNTRY.
Sample Output
NW S TH M FR L GD C Y.
#include<iostream>#include<algorithm>#include<string>#include<cstdio>#include<cstring>using namespace std;int main(){ bool vis[26]; char ch[75],res[75]; int i,cnt; while(gets(ch)) { cnt=0; memset(vis,0,sizeof(vis)); vis['A'-'A']=true; vis['E'-'A']=true; vis['I'-'A']=true; vis['O'-'A']=true; vis['U'-'A']=true; for(int i=0;ch[i]!='\0';i++) { if(isalpha(ch[i])) { if(!vis[ch[i]-'A']) { res[cnt++]=ch[i]; vis[ch[i]-'A']=true; } } else if(ch[i]==','||ch[i]=='.'||ch[i]=='?') { if(res[cnt-1]==' ') res[cnt-1]=ch[i]; else res[cnt++]=ch[i]; } else if(res[cnt-1]!=' '&&cnt!=0) { if(ch[i]==' ') { res[cnt++]=ch[i]; } } } res[cnt]='\0'; printf("%s\n",res); } return 0;}
0 0
- Extra Krunch
- Extra Krunch
- 1951 Extra Krunch
- poj 1951 extra krunch
- C - Extra Krunch
- poj 1951 Extra Krunch
- BNUOJ 14280 Extra Krunch
- POJ-1951-Extra Krunch
- poj 1951 Extra Krunch
- POJ 1951 Extra Krunch G++
- poj 1951 Extra Krunch 字符串处理水题
- Extra
- day3 extra
- extra-code
- Extra属性
- Extra Workloads
- poj 1951 模拟(Krunch字串)
- Extra Repositories for Ubuntu
- Python机器学习库SKLearn分类算法之朴素贝叶斯
- Python 文件操作 -- 常更
- 100道动态规划——40 CSUOJ 1889 Copying DNA 记忆化搜索 DP的感觉
- 母函数(生成函数)
- java VE 安装
- Extra Krunch
- MySQL-python-1.2.4b4.win32.-py2.7.exe安装失败,无法自动检测到python安装目录
- AOJ.850 电缆公司的烦恼 (二分+枚举)
- 【Unity编程】Unity动画系统(一)
- 2017浙江省选二试第四天游记
- 基础DP-数字三角形-白书练习(挑战程序设计竞赛2)
- 【Android】通过java代码动态添加控件
- Modeling and Troubleshooting Flow Control Valves
- A. The Monster