-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab10b3.c
More file actions
48 lines (39 loc) · 932 Bytes
/
lab10b3.c
File metadata and controls
48 lines (39 loc) · 932 Bytes
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
37
38
39
40
41
42
43
44
45
46
47
48
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
void inhoa(char *c)
{
for(int i =0; i< strlen(c);i++)
{
c[i]=tolower(c[i]);
}
c[0]=toupper(c[0]);
}
int main()
{
char c[1000];
gets(c);
printf("so ky tu trong cau: %d\n",strlen(c));
int cnt =0;
for(int i =0;i<strlen(c);i++)
{
c[i]=tolower(c[i]);
if(c[i]=='a'||c[i] == 'e'|| c[i]=='u'|| c[i]=='i'|| c[i]=='o')
{
cnt++;
}
}
printf("so ky tu nguyen am: %d va phan tram: %.2lf %%\n",cnt,100.0*cnt/strlen(c));
// chuan hoa
printf("da chuan hoa: ");
char* chuanhoa=strtok(c," \n\t"); int Space =0;
while(chuanhoa!=NULL)
{ ++Space;
inhoa(chuanhoa);
printf("%s ",chuanhoa);
chuanhoa=strtok(NULL," \n\t");
}
printf("\nso tu trong cau: %d ",Space);
return 0;
}