实在不知道叫啥 2018-10-25 14:29 采纳率: 0%
浏览 559
已采纳

关于选择结构顺序设计的问题....

#include
int main()
{
char ch;
scanf("%c",&ch);
if (ch=(ch>='0'&ch<='9'))
printf("digit\n",ch);
else if (ch=(ch>='A'&ch<='Z'))
printf("captial letter\n",ch);
else if (ch=(ch>='a'&ch<='z'))
printf("lower case letter\n",ch);
else if (ch=' ')
printf("blank spacer\n",ch);
else
printf("others\n");
return 0;
}

【输入形式】从键盘输入一个字符,以回车键结束。
【输出形式】

如果这个字符是数字,请显示:digit

如果这个字符是大写字母,请显示:capital letter

如果这个字符是小写字母,请显示:lower case letter

如果这个字符是空格,请显示:blank space

如果这个字符是其他字符,请显示:others

 我错哪儿了......
  • 写回答

2条回答 默认 最新

  • qq_38941327 2018-10-25 15:21
    关注

    #include
    int main()
    {
    char ch;
    scanf("%c", &ch);
    if (ch >= '0'&ch <= '9')
    printf("digit\n");
    else if (ch >= 'A'&ch <= 'Z')
    printf("captial letter\n");
    else if (ch >= 'a'&ch <= 'z')
    printf("lower case letter\n");
    else if (ch == ' ')
    printf("blank spacer\n");
    else
    printf("others\n");
    return 0;
    }

    
    

    判断ch要用==,不是=

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行