题解 | #变种水仙花#
变种水仙花
https://www.nowcoder.com/practice/c178e3f5cc4641dfbc8b020ae79e2b71
public class Program { public static void Main() { string result = ""; //个位 十位 百位 千位 万位 int ge = 0, shi = 0, bai = 0, qian = 0, wan = 0; //题目是五位数中的数,所以i是从1万开始的 for (int i = 10000; i < 100000; i++) { ge = i % 10; shi = i / 10 % 10; bai = i / 100 % 10; qian = i / 1000 % 10; wan = i / 10000; //规则看用例推敲就行了 if ( ( (wan * (qian * 1000 + bai * 100 + shi * 10 + ge)) + ((wan * 10 + qian) * (bai * 100 + shi * 10 + ge)) + ((wan * 100 + qian * 10 + bai) * (shi * 10 + ge)) + ((wan * 1000 + qian * 100 + bai * 10 + shi)*ge) == i)) result += i.ToString() + " "; } System.Console.WriteLine(result); } }