C#找出水仙花数
所谓水仙花数,指的是一个三位整数,其各位数字之立方和等于数字本身 例如:153 = 1 1 1 + 5 5 5 + 3 3 3 本例的核心问题在于对数位的提取,用最基础的数学思想,提取出对应位上的数字,要有严密的数学逻辑 using System ; namespace dome { class Program { static void Main ( string [ ] args ) { Console . WriteLine ( "水仙花数:" ) ; for ( int i = 100 ; i < 1000 ; i ++ ) { int g = i % 10 ; int s = i / 10 % 10 ; int b = i / 100 % 10 ; if ( g * g * g + s * s * s + b * b * b == i ) { Console . WriteLine ( i ) ; } } } } } 来源: CSDN 作者: 黑夜中的潜行者 链接: https://blog.csdn.net/qq_43562262/article/details/104538419