#include <stdio.h>
int main()
{
int i=1;
while(i<=100)
{
if (i%6==0)
printf("%d",i);
i++;
}
printf("%d\n",i);
return 0;
}
运行结果后面为什么会有个101呀
把6改成3或者其他数字还是有101,
#include <stdio.h>
int main()
{
int i=1;
while(i<=100)
{
if (i%6==0)
printf("%d",i);
i++;
}
printf("%d\n",i);
return 0;
}
运行结果后面为什么会有个101呀
把6改成3或者其他数字还是有101,
我觉得你首先要养成使用\n的好习惯。。。
#include<stdio.h>
int main(void)
{
int i = 1;
while (i <= 100 )
{
if (i % 6 == 0)printf("%d\t", i);
printf("%d\n",i++);
}
printf("\n%d\n", i);
return 0;
}
改成这样就容易理解多了
i=100时进入whie循环体执行了 i++
接着执行 print
所以会打印出101