描述
键盘输入一行字符,统计该字符串中英文字母的个数。设计一个函数:
int fun8(char *s);
该函数的功能是统计字符串 s 中英文字母的个数。
裁判测试程序样例:
#include <stdio.h>
#include <string.h>
int fun8(char *s);
int main() {
char s[100];
int count;
/* Input */
gets(s);
/* Calculate */
count = fun8(s);
/* Output */
printf("count=%d\n", count);
return 0;
}
/* 你的代码将被嵌在这里 */
输入
输入字符串(字符个数<100)。
输出
输出大写英文字母的个数。
输入输出示例
输入 | 输出 | |
示例 1 | | |
#include <stdio.h>
#include <string.h>
int fun8(char *s);
int main() {
char s[100];
int count;
/* Input */
gets(s);
/* Calculate */
count = fun8(s);
/* Output */
printf("count=%d\n", count);
return 0;
}
int fun8(char *s)
{
int longs=0,i;
for(i=0;s[i]!='\0';i++){
if(s[i]>='a'&&s[i]<='z'||s[i]>='A'&&s[i]<='Z'){
longs++;
}
}
return longs;
}