没有其他“如果"的“其他" [英] 'else' without a previous 'if'
本文介绍了没有其他“如果"的“其他"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我才刚刚开始学习C编程,所以我还不是真正的高级.忍受我!
I am just beginning to learn C programming, so I am not really on an advanced level. Bear with me!
我有这段代码,我想很容易理解我要做什么.但是我收到一个错误消息,说最后一个else之前没有if调用.
I have this piece of code, and I guess that it is pretty easy to understand what I am trying to do. However I get an error saying the last else is called without an if before it.
我怀疑问题是我在if和else之间的if-else语句.你们将如何解决?
I suspect that the problem is my if-else statement inbetween the if and else. How would you guys solve it?
int talet;
scanf("%d", &talet);
int i = 1;
while (i <= 99) {
int a; {
if (i % talet == 0 || talet == (i / 10) % 10 || talet == i % 10) {
if (talet % 10 == 0)
printf("\n");
else
continue;
}
printf("burr ");
else
printf("%d ", i);
}
i = i + 1;
}
推荐答案
问题出在括号里.缩进对于了解在何处打开和关闭括号很重要
The problem is with your brackets. Indenting is important to understand where to open and close your brackets
int talet;
scanf("%d",&talet);
int i=1;
while(i<=99)
{
int a;
if (i%talet==0 || talet==(i/10)%10 ||talet==i%10)
{
if (talet%10==0)
printf("\n");
else
continue;
printf("burr ");
}
else
{
printf("%d ",i);
}
i=i+1;
}
这篇关于没有其他“如果"的“其他"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文