ZKJ。。 2021-12-13 13:59 采纳率: 100%
浏览 17
已结题

为什么输出不了?求解答

#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);
}

  • 写回答

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条)

报告相同问题?

问题事件

  • 系统已结题 4月10日
  • 已采纳回答 4月2日
  • 创建了问题 12月13日

悬赏问题

  • ¥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代码移植没反应