'commit'
This commit is contained in:
35
C++专题课程/基础知识/水仙花数第二版本.cpp
Normal file
35
C++专题课程/基础知识/水仙花数第二版本.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
int fun(int n) {
|
||||
int b=n/100;
|
||||
int s=n/10%10;
|
||||
int g=n%10;
|
||||
int sum=b*b*b+s*s*s+g*g*g;
|
||||
if(sum==n)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
int main() {
|
||||
|
||||
int n=1210;
|
||||
do
|
||||
{
|
||||
cout<<n%10<<endl;;
|
||||
n/=10;
|
||||
}
|
||||
while(n!=0);
|
||||
|
||||
|
||||
|
||||
// int start=100,stop=380;
|
||||
// for(int i=start; i<=stop; i++) {
|
||||
// if(fun(i)==1) {
|
||||
// printf("%d ",i);
|
||||
// }
|
||||
// }
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user