| 
 
TA的每日心情|  | 开心 2014-6-18 08:29
 | 
|---|
 签到天数: 14 天 [LV.3]偶尔看看II 滴水大师  
 
 
	积分2345 
 | 
 
| 题目 
  
 解决代码及点评
 
 
 
 
 <pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"></pre><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code">/* 功能:写一函数判断某数是否“水仙花数”,所谓“水仙花数”是指一个三位数, 其各位数字立方和等于该数本身。      */    #include<stdio.h>  #include<stdlib.h>    int flower(int);            //判断参数是否为水仙花数,是返回1,否返回0    void main(){      int num;      scanf_s("%d",&num);  // 输入一个数      int flag = flower(num);     // 判断是否水仙花数               if (flag == 1)printf("YES");  // 如果是打印yes,否则打印no      else printf("NO");      system("pause");  }  // 判断水仙花数函数实现,根据题目要求判断即可  int flower(int n){      int b1 = n % 10;            //个位数      int b2 = n / 10 % 10;       //十位数      int b3 = n / 100;           //白位数      if (n == b1*b1*b1 + b2*b2*b2 + b3*b3*b3){          printf("%d = %d^3 + %d^3 + %d^3\n\n",n,b1,b2,b3);          return 1;      }      else return 0;  }</pre><br><br><br></pre></pre>  
 
 
 | 
 |