printf输出为什么上面会有零

代码:
int s ;
int x=0, y=0, z=0, a=0, b=0, x1=0, y1=0, z1=0;
for (s = 0; s <= 999; s++) {
x = s % 7; a = s / 7; y = a % 7; z = a /7;
x1 = s % 9; b = s / 9; y1 = b % 9; z1 = b / 9;
if (x1==z&&y1==y&&z1==x)
{
printf("%d\n", s);
printf("%d%d%d\n", x, y, z);
printf("%d%d%d\n", x1, y1, z1);
}
}

输出:
0
000
000
248
305
503
预想:
248
305
503

s的初始值是1,应该把for循环改一下
for (s = 1; s <= 999; s++)
你的x就是s%7,如果s=0,s%7也是0

如果对你有帮助,还请点个采纳,万分感谢!

for (s = 0; s <= 999; s++) 
改为:
for (s = 1; s <= 999; s++) 

s初始值为1。或者加上一个条件,不为0

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632