查看: 1028|回复: 6
|
帮忙下..... code有问题
[复制链接]
|
|
#include <stdio.h>
#include <conio.h>
void main()
{
int countsets = 0 , i ;
clrscr();
for ( i = 2 ; 1 ; i++ )
{ if ( i % 1 == 0 )
{ {countsets++;}
if (countsets == 100)
{break;}
}
else
{printf ("%d", i);
countsets++;
if (countsets ==100)
{break;}
}
}
getch();
}
可以Run了可是 printf里的内容都米有显示出来。。。。。。。 |
|
|
|
|
|
|
|
发表于 24-7-2007 07:52 PM
|
显示全部楼层
这里出问题吧?
for ( i = 2 ; 1 ; i++ ) |
|
|
|
|
|
|
|
发表于 25-7-2007 08:37 AM
|
显示全部楼层
% 1 which (is mathematically & 0) is always 0.. |
|
|
|
|
|
|
|

楼主 |
发表于 25-7-2007 06:09 PM
|
显示全部楼层
所以把一改成二? |
|
|
|
|
|
|
|
发表于 8-8-2007 02:07 PM
|
显示全部楼层
for loop 里除了问题。
% 也除了问题,不能用1,因为会永远得到0.
还有你的countset是用来做什么的?真个程序根本不可能到一百。所以就不能显示任何东西呀。 |
|
|
|
|
|
|
|

楼主 |
发表于 13-8-2007 11:45 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 2-9-2007 04:40 PM
|
显示全部楼层
这个出了问题。
if ( i % 1 == 0 ) <-- 任何数目除以1的余数都是0。 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|