题解 | #变种水仙花#
变种水仙花
https://www.nowcoder.com/practice/c178e3f5cc4641dfbc8b020ae79e2b71
#include <stdio.h>
int main() {
int i = 0;//初始化
for (i = 10000; i <= 99999; i++)//范围
{
int a1 = i / 10000;//千
int a2 = i % 10000;
int a3 = a1 * a2;
int b1 = i / 1000;//百
int b2 = i % 1000;
int b3 = b1 * b2;
int c1 = i / 100;//十
int c2 = i % 100;
int c3 = c1 * c2;
int d1 = i / 10;//个
int d2 = i % 10;
int d3 = d1 * d2;
int sum = a3 + b3 + c3 + d3;
if (sum == i)//判断
{
printf("%d ", i);
}
}
return 0;
}
C语言基础 文章被收录于专栏
里面较为详细的介绍了c语言的相关用法和有关题目。
