等式(a + b)<= n中的'a'的打印值可被x整除
给定方程式,程序必须找到'a'的值,其中a+b<=n并且也可以被x整除。
算法
START
Step 1 -> Declare start variables b=10, x=9, n=40 and flag=0, divisible
Step 2 -> Loop For divisible = (b / x + 1 ) * x and divisible <= n and divisible += x
IF divisible - b >= 1
Print divisible-1
Set flag=1
End
END
STOP示例
#include <stdio.h>
int main(int argc, char const *argv[]) {
int b=10, x=9, n=40, flag = 0;
int divisible;
for (divisible = (b / x + 1 ) * x ; divisible <= n; divisible += x) {
if ( divisible - b >= 1) {
printf("%d ", divisible - b );
flag = 1;
}
}
return 0;
}输出结果
如果我们运行上面的程序,那么它将生成以下输出
8 17 26
热门推荐
1 祝福语简短古诗词
10 新生祝福语简短8字
11 对儿子祝福语简短精辟
12 新年祝福语简短给孩子
13 朋友孩子考试祝福语简短
14 老人过大寿祝福语简短
15 三八简短祝福语给婆婆
16 恭喜朋友买车祝福语简短
17 大雪生日祝福语大全简短
18 元旦联谊祝福语简短精辟