Solution three digits: known xyz + yzz = n, where n is a positive integer, x, y, z are numbers (0-9), write a program determined x, y, z represent what numbers. If there is no solution, output "No Answer" Note: xyz represents a three-and yzz

Description Title:
Input
enter a positive integer n.

			输出
			输出一行,包含x、y、z的值,每个数值占4列。
			
			样例输入 
			532
			样例输出 
			   3   2   1
# include<stdio.h>
int main()
{
	int x,y,z,n,flag=1;
	scanf("%d",&n);
	for(x=1;x<=9;x++)
	{
		for(y=1;y<=9;y++)
		{
			for(z=0;z<=9;z++)
			{
				if(x*100+y*10+z+y*100+z*10+z==n)
				{
					printf("%4d%4d%4d",x,y,z);
					flag=0;
				}
			}
		}
	}
	if(flag)
	{
		printf("No Answer");
	}
	return 0;
}

Note: one hundred numbers can not be zero.

Published 43 original articles · won praise 1 · views 763

Guess you like

Origin blog.csdn.net/Du798566/article/details/104256343