gpt4 book ai didi

c - c 中的 dangling-else 问题到底是什么?

转载 作者:行者123 更新时间:2023-11-30 21:48:10 31 4
gpt4 key购买 nike

代码怎么能这样工作呢?哪些 if-else 语句相互链接?那么为什么输出是这样的“$$$$$”?

#include <stdio.h>
int main() {
int x = 11;
int y = 9;

if(x<10)
if(y>10)
puts("*****");
else
puts("#####");
puts("$$$$$");
return 0;
}

最佳答案

节省时间。使用自动格式化程序。

希望“为什么输出是这样的“$$$$$”?”是不言而喻的。

#include <stdio.h>
int main() {
int x = 11;
int y = 9;

if (x < 10)
if (y > 10)
puts("*****");
else
puts("#####");
puts("$$$$$");
return 0;
}

关于c - c 中的 dangling-else 问题到底是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59229960/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com