作业1的第1题参考程序解释

include <stdio.h>
#include <math.h>//后面用没?
int main()
{
    int m,n,t;
    int a,b,c,d;
    printf("请输入两个3位数的正整数\n");//多余,可以不要
    scanf("%d%d",&m,&n);
   if (m > n)
    {
        t = m;
        m = n;
        n = t;
    }
  for(t=m; t<=n;t++)//从m到n,如果是水仙数,输出,所以for要管到if

  {
      a=t/100;
        b=t/10%10;
        c=t%10;
        d=a*a*a+b*b*b+c*c*c;
         //}  ---不要
        if(t==d)
        {
            printf("%d\n",t);
  }
  }//和for对应
  return 0;
}

posted @ 2014-04-24 13:42  Liping的个人博客  阅读(243)  评论(0编辑  收藏  举报