'commit'
This commit is contained in:
17
C++专题课程/基础知识/判断任一3位数是否为水仙花数.cpp
Normal file
17
C++专题课程/基础知识/判断任一3位数是否为水仙花数.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main() {
|
||||
int b, s, g, n, sum;
|
||||
scanf("%d", &n);
|
||||
b=n/100;
|
||||
s=n/10%10;
|
||||
g=n%10;
|
||||
sum=b*b*b+s*s*s+g*g*g;
|
||||
if(sum==n)
|
||||
printf("Yes\n");
|
||||
else
|
||||
printf("No\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user