版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sunlanchang/article/details/88555059
题目描述
设a、b、c均是0到9之间的数字,abc、bcc是两个三位数,且有:abc+bcc=532。求满足条件的所有a、b、c的值。
输入描述:
题目没有任何输入。
输出描述:
请输出所有满足题目条件的a、b、c的值。
a、b、c之间用空格隔开。
每个输出占一行。
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
for (int a = 0; a < 10; a++)
{
for (int b = 0; b < 10; b++)
{
for (int c = 0; c < 10; c++)
{
int x = a * 100 + b * 10 + c;
int y = b * 100 + c * 10 + c;
if (x + y == 532)
printf("%d %d %d\n", a, b, c);
}
}
}
return 0;
}