[水仙花数]
这道题很简单,只要注意运算符的含义就行了.
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
while (true) {
int number;
cin >> number;
if (number == 0) {
return 0;
}
int a = 0;
//get hundred bit
a = number / 100;
int b = 0;
//get ten bit
b = (number / 10) % 10;
int c = 0;
//get sample bit
c = number % 10;
if (a*a*a + b*b*b + c*c *c == number) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
}
return 0;
}