c程序
来源:互联网 发布:大学生网购数据 编辑:程序博客网 时间:2024/06/14 02:23
题目:一个数如果恰好等于它的因子之和,这个数就称为“完数”。例如6=1+2+3.编程
找出1000以内的所有完数。
1. 程序分析:请参照程序<--上页程序14.
找出1000以内的所有完数。
1. 程序分析:请参照程序<--上页程序14.
2.程序源代码:
#include "stdio.h"
#include "conio.h"
main()
{
static int k[10];
int i,j,n,s;
for(j=2;j<1000;j++)
{
n=-1;
s=j;
for(i=1;i<j;i++)
{
if((j%i)==0)
{
n++;
s=s-i;
k[n]=i;
}
}
if(s==0)
{
printf("%d is a wanshu",j);
for(i=0;i<n;i++)
printf("%d,",k);
printf("%d\n",k[n]);
}
}
getch();
}
阅读全文
0 0
- C程序
- c 程序
- C程序
- C程序
- c程序。
- c程序
- c 程序
- c程序
- C程序
- C程序
- c程序
- c程序
- c程序
- c程序
- C程序
- c程序
- c程序
- c程序
- Codeforces 808C Tea Party
- c
- 怎样建索引及索引的分类,索引有什么好处,要注意一些什么问题,如会不会影响其他表?
- Sublime text 3最新版破解方法
- MyEclipse导入项目时报红叹号的解决方法
- c程序
- c++第五次上机实验
- Zephyr程序初探(5):thread程序
- hashMap原理
- laravel中的表单Form的使用
- Package libvirt was not found in the pkg-config search path
- Qt之QImageWriter
- vue之自定义指令
- php--条件语句