- 问题描述
-
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) - 输出
-
For each case, you should list all of the appeared syllables sorted by lexicographical and its times.
找出所有的形如ab的字符串,其中a为辅音,b为元音#include<stdio.h> #include<string.h> int num[30][30]; bool judge(char a,char b) { if(a!='a' && a!='e' && a!='i' && a!='o' && a!='u') if(b=='a'|| b=='e' || b=='i' || b=='o' || b=='u' ) return true; return false; } int main() { char a,b,temp; while(~scanf("%c%c",&a,&b)) { int i=0,j; memset(num,0,sizeof(num)); while(scanf("%c",&temp)) { if(temp=='\n') break; if(judge(a,b)) num[a-'a'][b-'a']++; a=b; b=temp; } if(judge(a,b)) num[a-'a'][b-'a']++; for(i=0;i<30;i++) for(j=0;j<30;j++) if(!num[i][j]) continue; else printf("%c%c %d\n",i+'a',j+'a',num[i][j]); } return 0; }