各位大佬,请帮忙看一下,为什么输出总为0

G-F-N66 G-F-N66 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#include <stdio.h>

int main()
{
int num,num0=0,num1=0,num2=0,num3=0,num4=0,num5=0;
char operation=0;
printf("Please think of a number less than 50 in your mind!\n");
printf("Then I will give you a set of cards, please note that if your numbers are in those cards\n");
printf("I will figure out the number a piece of cake after that\n");
printf("okay, let us try!\n");
printf("Enter 'q' to end input\n");
printf("You can input like that 0#卡片 or 2#卡片 :\n");

while(1)
{
scanf("%c",&operation);
if(operation == '0#卡片')
{
num0=1;
continue;
}
if(operation == '1#卡片')
{
num1=2;
}
if(operation == '2#卡片')
{
num2=4;
}
if(operation == '3#卡片')
{
num3=8;
}
if(operation == '4#卡片')
{
num4=16;
}
if(operation == '5#卡片')
{
num5=32;
}
if(operation == 'q')
{
num = num0+num1+num2+num3+num4+num5;
break;
}

}
printf("%d",num);
return 0;
}
这个输出为什么总是0啊?
...全文
评论 2
收藏 已收藏
分享
返回顶部
G-F-N66
C语言 70,039 成员 243,237 内容