forked from wenjun1055/c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path9.1.c
executable file
·36 lines (32 loc) · 830 Bytes
/
9.1.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
36
#include <stdio.h>
#include <ctype.h>
int main()
{
int num[7] = {0,0,0,0,0,0,0};
int i = 0;
char string[50], *ap;
printf("Please input a string:");
gets(string);
printf("Your input string is:%s\r\n\r\n", string);
for (ap = string; *ap != '\0'; ap++) {
if (iscntrl(*ap) != 0) {
num[0]++;
} else if (isspace(*ap) != 0) {
num[1]++;
} else if (isdigit(*ap) != 0) {
num[2]++;
} else if (islower(*ap) != 0) {
num[3]++;
} else if (isupper(*ap) != 0) {
num[4]++;
} else if (ispunct(*ap) != 0) {
num[5]++;
} else if (isprint(*ap) == 0) {
num[6]++;
}
}
for (i = 0; i < 7; i++) {
printf("i = %d, num = %d\r\n", i, num[i]);
}
return 0;
}