文章目录
[1408] Dolly Song
Please listen to this song. Is it familiar?
You know, the lyrics is "ba la du la di li @&**(&#(!*@&#(*!@&#(*!@&#". Well it's just a joke.
We need you to caculate how many syllables in this song.
To simplify this problem, we just assume a consonant followed a vowel(AEIOU) called a
syllable. For examples, 'ba', 'la', 'du' and so on are syllables.
You should caculate out the count of each syllable.
This problem contains several cases.
Each case is a line of string with only lowercase letters. (No longer than 65535)
Each case is a line of string with only lowercase letters. (No longer than 65535)
For each case, you should list all of the appeared syllables sorted by lexicographical and its times.
baulaubilibiliuuuauaja
ba 1 bi 2 ja 1 la 1 li 2
无
XadillaX
题意 :输入一个字符串 看其中的 2个字符的单词 辅音+元音的 单词的个数
思路 map记录即可
#include<stdio.h> #include<map> #include<string> #include<string.h> #include<algorithm> #include<iostream> using namespace std; map<string,int>mp; map<string,int>::iterator it; char s[70000]; int is(char ch1,char ch2 ) { if(ch1=='a'||ch1=='e'||ch1=='i'||ch1=='o'||ch1=='u') return 0; if(ch2=='a'||ch2=='e'||ch2=='i'||ch2=='o'||ch2=='u') return 1; return 0; } int main() { int i; string str; while(scanf("%s",s)!=EOF) { mp.clear(); int len=strlen(s); for(i=0;i<len-1;i++) { str=""; str+=s[i]; str+=s[i+1]; if(is(s[i],s[i+1])) mp[str]++; } for(it=mp.begin();it!=mp.end();it++) { //cout<<it->first<<" "<<it->second<<endl; printf("%s %d\n",it->first.c_str(),it->second); //it->second=0; } } return 0; }