读入一串字符串,去除空格和数字字符,输入以回车结束。

读入一串字符串,去除空格和数字字符,输入以回车结束。
【样例输入】abc 33 de
【样例输出】abcde
【样例说明】
最后输入的回车符不输出。输出结束无换行符。

使用getchar循环读入并处理即可
示例代码如下
有帮助望采纳~

#include <stdio.h>

int main(int argc, char const *argv[])
{
    char c;
    while ((c = getchar()) != '\n')
    {
        if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
        {
            putchar(c);
        }
        else
        {
            continue;
        }
    }
}

img

循环读取字符逐个判断即可
你题目的解答代码如下:

#include <stdio.h>

int main()
{
    char ch;
    while ((ch = getchar()) != '\n')
    {
        if ((ch < '0' || ch > '9') && ch != ' ')
        {
            printf("%c", ch);
        }
    }
    return 0;
}

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img