12、c程序中编程,统计一行中数字字符的个数。

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main()
{
    int j = 0,c=0;
    //char s[100]
    char s[100]={'8','a','a'};    
    //puts("请输入字符串:");
    //gets(s);
    //s={'1','2','3','1','a','e','q'};
    
    for (int i = 0; i < strlen(s); i++)
    {
        if ((s[i]<='9')&&(s[i]>='0')){
            j++;
        }
        else{
            c++;
        }
    }
    printf("数字字符的个数是:%d
", j);
    printf("字符的个数是:%d
", c);
    //system("pause");
    return 0;
}
原文地址:https://www.cnblogs.com/guojiusong/p/8023711.html