#include<stdio.h>
#include<string.h>
int main(){
char str[100],p;
int input(char p);
int count(char p);
p=str;
input(p);
count(p);
}
int input(char p){
int i=0;
for(;(p+i)=getchar()!='\n';i++);
}
int count(char p){
int a,b,c,d,i;
a=b=c=d=0;
for(i=0;(p+i)!='\n';i++){
if((p+i)=='\0')a=a+1;
else if((p+i)>='A'&&(p+i)<='Z')b=b+1;
else if((p+i)>='a'&&(p+i)<='z')c=c+1;
else d=d+1;
}
printf("大写字母个数:%d\n",b );
printf("小写字母个数:%d\n",c);
printf("空格个数: %d\n",a);
printf("其他字符个数:%d\n",d);
}
为什么输出不了?求解答
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- 南七灵 2021-12-13 14:12关注
#include <stdio.h> #include <string.h> int main() { char str[100], *p; int input(char *p); int count(char *p); p = str; input(p); count(p); } int input(char *p) { gets(p); } int count(char *p) { int a, b, c, d, i; a = b = c = d = 0; for (i = 0; *(p + i) != '\0'; i++) { if (*(p + i) == ' ') a = a + 1; else if (*(p + i) >= 'A' && *(p + i) <= 'Z') b = b + 1; else if (*(p + i) >= 'a' && *(p + i) <= 'z') c = c + 1; else d = d + 1; } printf("大写字母个数:%d\n", b); printf("小写字母个数:%d\n", c); printf("空格个数: %d\n", a); printf("其他字符个数:%d\n", d); }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
- ¥20 神经网络Sequential name=sequential, built=False
- ¥16 Qphython 用xlrd读取excel报错
- ¥15 单片机学习顺序问题!!
- ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
- ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
- ¥15 相敏解调 matlab
- ¥15 求lingo代码和思路
- ¥15 公交车和无人机协同运输
- ¥15 stm32代码移植没反应