我不知道这个问题 [英] i donno the problem

查看:72
本文介绍了我不知道这个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include< stdio.h>

#include< conio.h>

main()

{

int n;

while(1< = n< = 100)

{

printf("%d", n);

}

}


现在这段代码可以无限地输出783 ......如果数字

介于1到100之间,然后它应该是无印刷的,否则它根本不应该打印
///为什么会发生这种情况???

#include<stdio.h>
#include<conio.h>
main()
{
int n;
while(1<=n<=100)
{
printf("%d ",n);
}
}

Now this code prints something like 783 infinitely.....if the number
is between 1 to 100 then it should be printed infinetely else it
should not be printed at all///why is it so happening???

推荐答案

" ashwin700" < mi ************** @ gmail.com写信息

新闻:ac **************** ****************** @ a3g2000p rm.googlegroups.com ...
"ashwin700" <mi**************@gmail.comwrote in message
news:ac**********************************@a3g2000p rm.googlegroups.com...

#include< stdio.h> ;

#include< conio.h>

main()

{

int n;

while(1< = n< = 100)

{

printf("%d",n);

}

}


现在这段代码无限打印783这样的数字......如果数字是

介于两者之间1到100然后它应该是无印刷的其他它

根本不应该打印///为什么会发生这种情况?
#include<stdio.h>
#include<conio.h>
main()
{
int n;
while(1<=n<=100)
{
printf("%d ",n);
}
}

Now this code prints something like 783 infinitely.....if the number
is between 1 to 100 then it should be printed infinetely else it
should not be printed at all///why is it so happening???



n未初始化(因此它可以是任何东西,包括783)

" 1< = n< = 100"并不意味着n在1和100之间。而是像

"(1小于或等于n)小或等于100这是永远的

是的,因为表达式(1小于或等于n)的任何结果

将小于或等于100(它将是1或0)

因此它将继续打印n,永远,n在功能上是随机的,并且

不会改变。


你可能想试试


#include< stdio.h>

#include< conio.h>

main( )

{

int n;

while(n< =&& n> 0)

{

printf("%d",n);

}

}


它仍然没有意义,但至少条件会做你的意思

n is not initialized (so it could be anything, including 783)
"1<=n<=100" does Not mean "n is between 1 and 100" but rather something like
"(1 is smaller or equal to n) is small or equal to 100" which is allways
True because any outcome of the expression "(1 is smaller or equal to n)"
will be smaller or equal to 100 (it will be either 1 or 0)
Therefore it will keep printing n, forever, n is functionally random and
will not change.

you may want to try

#include<stdio.h>
#include<conio.h>
main()
{
int n;
while(n<=100 && n>0)
{
printf("%d ",n);
}
}

it will still not make sense but atleast the condition will do what you mean


" Harold Aptroot" < ha ************ @ gmail.com写信息

news:63 ****************** *********@cache100.multik abel.net ...
"Harold Aptroot" <ha************@gmail.comwrote in message
news:63***************************@cache100.multik abel.net...

" ashwin700" < mi ************** @ gmail.com写信息

新闻:ac **************** ****************** @ a3g2000p rm.googlegroups.com ...
"ashwin700" <mi**************@gmail.comwrote in message
news:ac**********************************@a3g2000p rm.googlegroups.com...

> #include< stdio .h>
#include< conio.h>
main()
{
int n;
while(1< = n< = 100) {
printf("%d",n);
}


现在这段代码无限打印出类似783的内容.....如果数字
介于1到100之间,然后它应该是无印刷的,否则它根本不应该打印///为什么会发生这种情况?
>#include<stdio.h>
#include<conio.h>
main()
{
int n;
while(1<=n<=100)
{
printf("%d ",n);
}
}

Now this code prints something like 783 infinitely.....if the number
is between 1 to 100 then it should be printed infinetely else it
should not be printed at all///why is it so happening???



n未初始化(因此它可能是任何东西,包括783)

" 1< = n< = 100"并不意味着n在1和100之间。而是像

之类的(1小于或等于n)小或等于100。这是

总是正确的,因为表达式的任何结果(1小于或等于

到n)将小于或等于100(它将是1或0)


n is not initialized (so it could be anything, including 783)
"1<=n<=100" does Not mean "n is between 1 and 100" but rather something
like "(1 is smaller or equal to n) is small or equal to 100" which is
allways True because any outcome of the expression "(1 is smaller or equal
to n)" will be smaller or equal to 100 (it will be either 1 or 0)



实际上,对于True,允许除0以外的任何值,但至少

与您的编译器True最终小于等于100(可能是

42或-1或-666但是)

actually, for True any value other than 0 would be allowed, but at least
with your compiler True ends up being smaller of equal to 100 (it could be
42 or -1 or -666 however)


因此它将继续打印n,永远,n在功能上是随机的,并且

不会改变。


你可能想要尝试


#include< stdio.h>

#include< conio.h>

main()

{

int n;

while(n< =&& n> 0)

{

printf("%d",n);

}

}


它仍然没有意义但至少这个条件会做你的事情

意味着
Therefore it will keep printing n, forever, n is functionally random and
will not change.

you may want to try

#include<stdio.h>
#include<conio.h>
main()
{
int n;
while(n<=100 && n>0)
{
printf("%d ",n);
}
}

it will still not make sense but atleast the condition will do what you
mean


9月14日,5:14 * pm,Harold Aptroot ; < harold.aptr ... @ gmail.comwrote:
On Sep 14, 5:14*pm, "Harold Aptroot" <harold.aptr...@gmail.comwrote:

" ashwin700" < mishra.ashwin ... @ gmail.com写信息


新闻:ac ********************* ************* @ a3g2000p rm.googlegroups.com ...
"ashwin700" <mishra.ashwin...@gmail.comwrote in message

news:ac**********************************@a3g2000p rm.googlegroups.com...

#include< stdio.h>

#include< conio.h>

main()

{

* * int n;

* * while(1< = n< = 100)

* * {

* * * printf("%d",n);

* *}

}
#include<stdio.h>
#include<conio.h>
main()
{
* *int n;
* *while(1<=n<=100)
* *{
* * * printf("%d ",n);
* *}
}


现在这段代码无限地打印出像783这样的东西.... 。如果数字

介于1到100之间那么它应该是无印刷的,否则

根本不应该打印///为什么会发生这种情况?
Now this code prints something like 783 infinitely.....if the number
is between 1 to 100 then it should be printed infinetely else it
should not be printed at all///why is it so happening???



n未初始化(因此它可能是任何东西,包括783)

" 1< = n< = 100"并不意味着n在1和100之间。而是像

"(1小于或等于n)小或等于100这是永远的

是的,因为表达式(1小于或等于n)的任何结果

将小于或等于100(它将是1或0)

因此它将继续打印n,永远,n在功能上是随机的,并且

不会改变。


你可能想试试


#include< stdio.h>

#include< conio.h>

main( )

{

* * int n;

* * while(n <= 100&& n> 0)

* * {

* * * printf("%d",n);

* *}


}


n is not initialized (so it could be anything, including 783)
"1<=n<=100" does Not mean "n is between 1 and 100" but rather something like
"(1 is smaller or equal to n) is small or equal to 100" which is allways
True because any outcome of the expression "(1 is smaller or equal to n)"
will be smaller or equal to 100 (it will be either 1 or 0)
Therefore it will keep printing n, forever, n is functionally random and
will not change.

you may want to try

#include<stdio.h>
#include<conio.h>
main()
{
* *int n;
* *while(n<=100 && n>0)
* *{
* * * printf("%d ",n);
* *}

}



这里也会无限打印或不打印

任何东西。

看,n根本没有改变。

所以真的需要检查程序的目的


-

vIpIn


Here also, it will print either infinitely or will not print
anything.
see, n is not being changed at all.
so really need to check the purpose of program

--
vIpIn


这篇关于我不知道这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆