2010
2016-03-28 09:12
155 查看
水仙花数
三位数的个 十 百 位的立方和等于三位数自己的数
参考答案
1-1000只有5个水仙花数:1 153 370 371 407
三位数的个 十 百 位的立方和等于三位数自己的数
#include <stdio.h> int main() { int m, n,i,j,a,b,c; while (scanf_s("%d %d",&m,&n)) { for (j = 0,i = m;i <=n;i++) { a = i / 100; b = i / 10 % 10; c = i % 10; if (a*a*a + b*b*b + c*c*c == i) { printf("%d ",i); j++; } } if (j == 0) printf("no answer"); printf("\n"); } }
参考答案
1-1000只有5个水仙花数:1 153 370 371 407
#include<stdio.h> int main() { int b, l, c, i; int a[] = {1, 153, 370, 371, 407}; while (scanf("%d%d", &b, &l) != EOF) { c = 0; for (i = 0 ; i < 5 ; i++) { if (a[i] >= b && a[i] <= l) printf(c++ ? " %d" : "%d", a[i]); } printf(c ? "\n" : "no\n"); } return 0; }
相关文章推荐
- paper 49:论文退稿?审稿人帮你总结了22个能避免的常见问题
- android 漂亮的开源ui框架
- 23 运算符重载(二)
- SQL_Group By的使用
- 字符串的本地化
- java.作业4 看电视2
- 山东ACM省赛历届入口
- 无线监听工装使用说明
- SQL_技术知识
- ASP.NET MVC Form验证
- wordpress 打开卡在1.gravatar.com
- 常见的transformation 和 Action
- JVM类加载机制(转载)
- Linux C高级编程——文件操作之系统调用
- 排序算法--归并排序法
- 【代码笔记】获得现在的周的日期
- 2016.03.27回顾
- 【MySQL】主备复制
- gitlab init project
- 【代码笔记】获得现在的周的日期