bai tap xau
#include<stdio.h>
#include<string.h>
int demkituthuong(char *s);
int demkituhoa(char *s);
char *daoxau(char *s);
int main()
{
char s[255];
printf("Nhap xau:");
gets(s);
printf("Xau vua nhap:%s
",s);
printf("So ki tu thuong trong xau:%d
",demkituthuong(s));
printf("So ki tu hoa trong xau:%d
",demkituhoa(s));
printf("Xau dao nguoc:%s
",daoxau(s));
system("pause");
return 0;
}
int demkituthuong(char *s)
{
int n=strlen(s);
int i,dem=0;
for(i=0;i<n;++i)
if(s[i]>='a'&&s[i]<='z')dem++;
return dem;
}
int demkituhoa(char *s)
{
int n=strlen(s);
int i,dem=0;
for(i=0;i<n;++i)
if(s[i]>='A'&&s[i]<='Z')dem++;
return dem;
}
char *daoxau(char *s)
{
char *s1=strdup(s);
strrev(s1);
return s1;
}
Bạn đang đọc truyện trên: Truyen247.Pro