第二个C语言代码

有问题,还没找出哪里出错了

输入一串字符,问号结束
统计1~9各出现的次数

***************************************************************************************
 
#include<stdio.h>
void main()
{
    char *ps,s;
    int i,n,m;
    char str[1000];
    printf("请输入字符串(以问号结尾) ");
    //gets(str);

    scanf("%s",&str);
   
for(m=0;m<=9;m++)
{
    s=m;
    ps=str;
        for (i=0;*ps!='';i++)
            {
                ps=str+i;
                for(n=0;*ps==s && *ps!='?';)
                    n++;
            printf("字符串中%d",m);
            printf("的个数是%d ",n);
            }
}
}

****************************************************************************************


#include<stdio.h>
void main()
{
    char *ps,s;
    int i,n,m;
    char str[1000];
    printf("请输入字符串(以问号结尾) ");
    //gets(str);

    scanf("%s",&str);
   
for(m=0;m<=9;m++)
{
    s=m;
    ps=str;
    for(n=0;*ps==s && *ps!='?';n++)
    {
        for (i=0;*ps!='';i++)
            ps=str+i;
    }
    printf("字符串中%d",m);
    printf("的个数是%d ",n);
}
}


欢迎访问我的的博客:www.wshunli.com

-------------------

已迁移文章:

VMware 12安装Mac OS X 10.10

http://www.wshunli.com/posts/65583447.html 

Tomcat安装配置

http://www.wshunli.com/posts/c8d48a24.html 

原文地址:https://www.cnblogs.com/wangshunli/p/3972275.html