77问答网
所有问题
C语言编写一个函数,在主函数中输入一个字符串,输出小写字母的个数。
如题所述
举报该问题
其他回答
第1个回答 2016-12-06
#include <
stdio.h
>
int count(char *s)
{
int r=0;
while(*s)
{
if(*s>='a'&&*s<='z')
r++;
s++;
}
return r;
}
int main()
{
char s[200];
scanf("%s",s);
printf("小写字母个数为%d\n",count(s));
return 0;
}
本回答被网友采纳
第2个回答 2016-12-06
void main(){
char a[100],b[100];
gets(a);
fun(a,b);
}
void fun(char a[],char b[]){
int i=0;
int j=0;
for(i=0;a[i]!='\0';i++){
if(a[i]>='a'&&a[i]<='z'){
b[j++]=a[i];
}
}
b[j]='\0';
}
相似回答
写一个函数,
统计
字符串里小写字母的个数c语言
答:
switch(c){ case '\n':return 1;case ' ':(*w)++;break;default:if(c>='a'&&c<='z')(*l)++;} return 0;}
C语言编写一个函数
统计一
串字符
中
小写字母的个数,
该函数参数为
一个字符
...
答:
int num_str(char str[]){ int num= 0;for(int i= 0; str[i]!='\0'; i++)if(str[i]>= 'a' && str[i]<= 'z' )num++;return num;} void
main
(){ char s[100];puts("请
输入字符串
:");gets(s);printf("%d\n", num_str(s));} ...
c语言
输入
一
串字符串,
统计并
输出
其中的大写字母、
小写字母
、
数字字符
...
答:
printf("
小写字母
字符数量:%d\n", suma);printf("大写
字母字符
数量:%d\n", sumA);} 在程序中,我们使用`gets`函数获取输入,但请注意,在现代C标准中,`gets`不安全,推荐使用`fgets`或`scanf`替换。接下来,通过指针`p`逐个检查
字符,
如果字符是数字(ASCII值在'0'到'9'之间),则增加`sum...
c语言
输入
一
串字符串,
统计并
输出
其中的大写字母、
小写字母
、
数字字符
...
答:
void
main
(){ char a[100];int sum0=0,suma=0,sumA=0;gets(a);char*p;for(p=a;*p!='\0';p++){ if(*p>='0'&&*p<='9')sum0+=1;else if(*p>='a'&&*p<='z')suma+=1;else if(*p>='A'&&*p<='Z')sumA+=1;} printf("
数字字符
数量:%d\n
小写字母字符
数量:%d\n大写...
C语言
编程
在主函数中输入一个字符串
利用函数求得字符串中大写
字母小写
字...
答:
include <stdio.h>#include <ctype.h>int
main
(void){ char ch[100]; void count(char * p); printf("请
输入字符串
: "); gets(ch); count(ch); return 0;}void count(char * p){ int upp=0, low=0, digi=0, spa=0, oth=0; for (int i = 0; p[i]; ++i) { if ...
...count
1
(char *p),统计
输入字符串中
的
小写字母的个数
答:
统计
输入字符串
中的数字
的个数,在主函数中输入1,
执行count
1函数,
输入2,执行count2函数。(同一个指针指向不同的函数)//
c语言
实现 visual studio 2010编译通过 编码:字符集UNICODE / //#include "stdafx.h"include <stdio.h> include <stdlib.h> include <string> using namespace std;int ...
用
C语言编写一个
程序
,输入一个字符串,
统计其中各个字符出现的次数_百 ...
答:
define _CRT_SECURE_NO_WARNINGS//VS环境下需要,VC不需要 include<stdio.h> int
main
(){ char c = 0;//定义
输入字符
变量 int num_count = 0;//数字个数 int bigalp_count = 0;//大写字母个数 int littlealp_count = 0;//
小写字母个数
int emp_count = 0;//空格个数 int els_...
大家正在搜
c语言的字符输出函数是什么
c语言字符串函数大全
c语言字符串函数库
c语言字符串匹配函数
c语言字符串连接函数
c语言如何输入字符串
字符串输入函数
c语言输出字符串
字符串复制函数编写
相关问题
C语言:写一个函数,求一个字符串的长度.在main函数中输入...
C语言编程:写一个函数,求一个字符串的长度,在main函数中...
用C语言写一个函数,使输入的字符串按反序存放,在主函数中输入...
C语言题目:写一个函数,求一个字符串的长度,在main函数中...
C语言编程,写一个函数,使输入的一个字符串按反序存放,在主函...
C语言编程,写一个函数,使输入的一个字符串按反序存放,在主函...
.编写函数,将给定字符串的大写字符转换为小写字符。在主函数中...
用C语言编写程序在主函数中输入一个字符串,编写函数实现将字符...