题解 | 变种水仙花

变种水仙花

https://www.nowcoder.com/practice/c178e3f5cc4641dfbc8b020ae79e2b71

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
int cm(int n)
{
	int a = n / 10000;
	int b = n % 10000;
	int c = n / 1000;
	int d = n % 1000;
	int e = n / 100;
	int f = n % 100;
	int g = n / 10;
	int h = n % 10;
	if (a * b + c * d + e * f + g * h == n)
	{
		return 1;
	}
	
	return 0;
}
int main()
{
	for (int i = 10000; i <= 99999; i++)
	{
		if (cm(i))
		{
			printf("%d ", i);
		}
	}
	return 0;
}

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务