关于 控制语句,有点意思
题目标题:abc+cba=1333题目描述:
已知abc+cba=1333,其中a,b,c均为一位数,编程求出所有满足条件的a,b,c所有组合。 (知识点:控制语句)
输入描述:
无
输出描述:
输出数据为多组,每组两个整形数;
样式输入:
无
样式输出:
123 321
456 654
遍历。。。枚举。。。有什么想法?
程序代码:#include <stdio.h>
int main()
{
int a, b, c;
int temp;
for (b = 0;b <= 9;++b)
{
temp = 1333 - 20 * b;
if (temp % 101) continue;
temp /= 101;
for (a = 9;a > 0;--a)
{
if ((c = temp - a) > 9)
break;
printf("%d%d%d + %d%d%d = 1333\n", a, b, c, c, b, a);
}
}
return 0;
}