ET


私信TA

用户名:wbc

访问量:59291

签 名:

人生苦短,我TM直接py

等  级
排  名 58
经  验 10336
参赛次数 3
文章发表 68
年  龄 0
在职情况 学生
学  校 东北大学
专  业 计算机科学与技术

  自我简介:

自2020起转python了。。。 C++兼容C,所以不要问为什么我所有的提交都是C++的.... 不AC,毋宁死,代码越短越好,思路越清奇越好hhhhhhhh

解题思路:
分四个变量统计就行




注意事项:
为什么回车不算字符

为什么回车不算字符

为什么回车不算字符



参考代码:

#include <stdio.h>

int main() {
    char ch;
    int letter = 0;
    int number = 0;
    int space = 0;
    int other = 0;
    while (scanf("%c", &ch)!=EOF && ch != '\n') {
        if (ch == ' ')
            space++;
        else if (ch <= '9' && ch >= '0')
            number++;
        else if ((ch <= 'z' && ch >= 'a') || (ch <= 'Z' && ch >= 'A'))
            letter++;
        else
            other++;
    }
    printf("%d %d %d %d\n", letter, number, space, other);
    return 0;
}


 

0.0分

7 人评分

  评论区

这不是c的描述吗?为什么说是c++的
2019-03-28 23:28:09
char ch和 (scanf("%c", &ch)!=EOF && ch != '\n') 什么意思
2017-12-11 13:04:11
  • «
  • 1
  • »