タイトル説明
母音の数をカウントする文字列を入力します。母音は、()関数を必要と母音は、残りの機能は)メイン関数(に実装するかどうかを決定するために使用されます。
母音INT(チャーCH)
{
// chが母音である場合には、そうでない場合は0、1を返します
}
この質問は、C / C ++コードの配信である場合にのみ、母音関数定義部、その他のコンテンツの提出、コンパイルエラーを提出しました。
エントリー
文字列の長さを入力します。1000、キャリッジリターン。
輸出
整数出力は、母音の数を示します。別の行に出力します。
サンプル入力
こんにちは世界!
サンプル出力
3
チップ:
そこAEIOU AEIOU除く1つの母音
2 GETCHAR())(現在の読み出し文字がキャリッジのscanfを読み取ることができる返しうまく読み取るの数を返します
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int vowel(char ch)
{
//如果ch是元音,返回1,否则返回0
switch (ch)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
return 1;
break;
default:
return 0;
break;
}
}
int main(){
char ch;
int count = 0;
while ((ch=getchar())!='\n')
{
count += vowel(ch);
}
printf("%d",count);
}