当前位置: 代码迷 >> 综合 >> Nswoj每日一题:水仙花数
  详细解决方案

Nswoj每日一题:水仙花数

热度:32   发布时间:2023-10-31 18:09:40.0

[水仙花数]

这道题很简单,只要注意运算符的含义就行了.
#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 bita = number / 100;int b = 0;//get ten bitb = (number / 10) % 10;int c = 0;//get sample bitc = number % 10;if (a*a*a + b*b*b + c*c *c == number) {cout << "Yes" << endl;}else {cout << "No" << endl;}}return 0;
}

  相关解决方案