输入一行字符串,输出其中的小写字母,并统计其中小写字母的个数。
时间: 2024-06-13 21:05:37 浏览: 20
输入一行字符串,输出其中的小写字母,并统计其中小写字母的个数。
```c
#include <stdio.h>
#define N 100
void arr_putout(char a[]); //输入字符串函数
void arr_putin(char a[]); // 输出字符串函数
void stat(char a[],int s[], int n); //统计字母个数函数
void arr_putin(char a[]){
scanf("%s",a);
}
void arr_putout(char a[]){
printf("%s",a);
puts("");
}
void stat(char a[],int s[], int n){
int i = 0;
for(int i = 0;i < n;i++){ //统计个数
if('a'<=a[i] && a[i]<='z'){
s[a[i]-'a'] +=1;
printf("%c",a[i]); //输出小写字母
}
}
puts("");
for(int i = 0;i < 26;i++){ // 遍历输出
printf("小写字母%c:%d次\n",i+97,s[i]); //i+97为 abcd
}
}
int main(int argc, const char *argv[]) {
char one[N] = {0};
int small[N] = {0};
printf("请输入:\n");
arr_putin(one);
printf("统计的字符串为:\n");
arr_putout(one);
printf("小写字母为:\n");
stat(one,small,N);
return 0;
}
```
相关推荐
![asm](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)