xcdh-lzj 2021-11-18 17:56 采纳率: 100%
浏览 37
已结题

如果输入一个a,那么iCheck不是等于0吗,这样子的话输出就是错的了,为什么?

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

int main()
{
char cLetter;
int iInRange, iCheck, i, iLetter;
i = 1;
while (i)
{
printf("输入一个字母, 判断元音与辅音. 如果想退出,请输入“0”。\n");
scanf("%c", &cLetter);
getchar();
printf("----------------------------------------------------------------------\n");
iLetter = (int)cLetter;
iCheck = isalpha(iLetter);
if (iCheck)
{
iInRange = (cLetter == 'a') || (cLetter == 'e') || (cLetter == 'i') || (cLetter == 'o') || (cLetter == 'u') || (cLetter == 'A') || (cLetter == 'E') || (cLetter == 'I') || (cLetter == 'O') || (cLetter == 'U');
if (iInRange)
{
printf("字母 %c 是元音字母!\n", cLetter);
printf("----------------------------------------------------------------------\n");
continue;
}
else
{
printf("字母 %c 是辅音字母!\n", cLetter);
printf("----------------------------------------------------------------------\n");
continue;
}
}
else if (iCheck == 0)
{
if (iLetter != 48)
{
printf("Error input!\n");
printf("----------------------------------------------------------------------\n");
continue;
}
else if ((int)cLetter == 48)
{
printf("Bye bye~~~!\n");
printf("----------------------------------------------------------------------\n");
i = (int)cLetter - 48;
}
}
}
return 0;
}

  • 写回答

1条回答 默认 最新

  • CSDN专家-sinJack 2021-11-18 18:02
    关注

    iCheck = isalpha(iLetter);
    a是英文字母,返回的结果是1,为什么会等于0?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 11月26日
  • 已采纳回答 11月18日
  • 创建了问题 11月18日

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测