-
Notifications
You must be signed in to change notification settings - Fork 0
/
7.28-test.c
35 lines (30 loc) · 875 Bytes
/
7.28-test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <ctype.h>
#include <string.h>
//C++ Primer Plus 第六章编程练习第7题C语言实现
int main(void)
{
int vowels_number = 0;
int consonants_number = 0;
int others = 0;
char words[20];
printf("Enter words (q to quit):\n");
while (scanf("%s", words) && (strcmp(words, "q") != 0))
{
if (isalpha(words[0]))
{
if ((words[0] == 'a') || (words[0] == 'e') || (words[0] == 'i') || (words[0] == 'o') || words[0] == 'u'
|| (words[0] == 'A') || (words[0] == 'E') || (words[0] == 'I') || (words[0] == 'O') || words[0] == 'U')
vowels_number++;
else
consonants_number++;
}
else
others++;
}
printf("%d words beginning with vowels\n", vowels_number);
printf("%d words beginning with consonants\n", consonants_number);
printf("%d others\n", others);
return 0;
}