Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
112808 张新福 水仙花数 C++ Accepted 1 MS 276 KB 503 2025-03-13 15:03:10

Tests(10/10):


Code:

#include <bits/stdc++.h> using namespace std; int main(){ int f,b,i,g,s,y,c=0,j,t; bool q=false; cin>>f>>b; int a[b]; for(i=f;i<=b;i++){ g=i%10; s=i/10%10; y=i/100; if(g*g*g+s*s*s+y*y*y==i){ q=true; a[c]=i; c++; } } for(i=1;i<=c-1;i++){ for(j=0;j<=c-i-1;j++){ if(a[j]>a[j+1]){ // t=a[j]; // a[j]=a[j+1]; // a[j+1]=t; swap(a[j],a[j+1]); } } } if(q==true){ for(i=0;i<c;i++){ cout<<a[i]<<" "; } }else{ cout<<"no"; } }