文章

36

粉丝

0

获赞

4

访问

10.8k

头像
字符个数 题解:c
P1042 重庆大学机试题
发布于2024年3月6日 11:00
阅读数 267

#include <stdio.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>

int main(void) {
    char s[1000];
    int eng=0,math=0,space=0,c=0;
    gets(s);
    for(int i=0;i<strlen(s);i++){
        if((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z')) eng++;
        if(s[i]>='0'&&s[i]<='9') math++;
        if(s[i]==' ') space++;
    }
    printf("%d %d %d %d",eng,math,space,strlen(s)-eng-math-space);
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发