C语言编程,麻烦高手帮忙改错。谢谢

2025-05-20 05:30:24
推荐回答(2个)
回答1:

那句

if(j%"%d"==0&&j%"%d"==0 ,a ,b)

 应该改成

if(j % a == 0 && j % b == 0)

这是因为 取模 % 运算要求两边是 int 整型,但是你却把 "%d" 给放上去了。因为  "%d" 是一个3个字符的字符串,所以类型为 const char[3],这样就会出现 “invalid operands of types `int' and `const char[3]' to binary `operator%'” 这个错误了。


小力庭 2013-4-20 欢迎到我微博上切磋交流

weibo.com/litingsoft

回答2:

这个。。。汗。。。
%d 什么的在格式化输出时用的,在其他地方直接用变量的
改为
if(j%a ==0 && j%b == 0)