交社保多少钱
高考成绩公布后,许欣悦决定报考就在本地的江西师专,选了喜欢的电子商务专业。, 鲁网11月28日讯11月25日,郯城县召开市派第五批第一书记工作座谈会。
题目 :C语言统计英文字母,空格 数字和其他字符的数目 这道题怎么做?
要解决这个问题,你可以按如下步骤编写一个C程序:
1. 在程序的开头,引入所需的头文件:
```c
#include
#include
```
2. 声明一个函数来统计不同字符的数量:
```c
void countCharacters(char* str, int* letters, int* spaces, int* digits, int* others) {
int i = 0;
char c;
*letters = *spaces = *digits = *others = 0;
while ((c = str[i++]) != '0') {
if (isalpha(c)) {
(*letters)++;
} else if (isspace(c)) {
(*spaces)++;
} else if (isdigit(c)) {
(*digits)++;
} else {
(*others)++;
}
}
}
```
在这个函数中,我们使用指针来更新传递给函数的变量。
3. 在主函数中调用这个函数,并输出结果:
```c
int main() {
char str[100];
printf("请输入一段字符串:");
fgets(str, sizeof(str), stdin);
int letters, spaces, digits, others;
countCharacters(str, &letters, &spaces, &digits, &others);
printf("字母的数量:%dn", letters);
printf("空格的数量:%dn", spaces);
printf("数字的数量:%dn", digits);
printf("其他字符的数量:%dn", others);
return 0;
}
```
在主函数中,我们首先声明一个字符串数组来存储用户输入的字符串。然后,通过调用`fgets`函数从标准输入中获取字符串。接下来,我们声明用于存储不同字符数量的变量,并调用`countCharacters`函数来计算它们的数量。最后,我们使用`printf`函数输出结果。
这样,当用户运行程序时,它将要求用户输入一个字符串,并输出字符的统计信息。
近年来,内蒙古呼和浩特市积极推进奶业振兴,支持龙头企业加强科技创新,提升奶业自动化、智能化生产水平,同时不断延伸产业链条,形成奶业全产业链发展格局,进一步增强奶业质量和效益,为当地经济高质量发展添活力。,局党组成员、副局长黄欣荣宣读《铜仁市碧江区住房和城乡建设局关于陈文江同志退休的通知》等9位同志的退休文件;
王志文在天道中的经典台词
王志文是中国影
本文共有54人参与回答,点击这里发表你的个人建议吧!