杭电ACm水仙花数2010谁能帮忙分析一下两段代码的区别;第二个通不过啊
#include <stdio.h>int main(){ int m,n,a,b,c,d; while(scanf("%d %d",&m,&n)!=EOF) { d=0; //每次输入要初始化个数。 while(m<=n) { a=m%10; b=(m%100)/10; c=m/100; if(a*a*a+b*b*b+c*c*c==m) { if(d==0) printf("%d",m); else printf(" %d",m); d++; } m++; } if(d==0) printf("no\n"); else printf("\n");} return 0;}
#include <iostream>using namespace std;int main(){ int m,n,i; int a,b,c,j=0,t=1; while (cin>>m>>n&&m>=100&&m<=n&&n<=999) { j=0; for(i=m;i<=n;i++) { a=i/100; b=(i-a*100)/10; c=i%10; if((a*a*a+b*b*b+c*c*c)==i) { t=0; if(j==0) cout<<i; else cout<<" "<<i; j++; } } if(t) cout<<"no"; cout<<endl; }return 0;}